update_proposals.rkt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #lang racket
  2. (require db)
  3. ; load configuration file
  4. (require (file "config.rkt"))
  5. ; set up a condensed prompt for getting information
  6. (define (getinput prompt)
  7. (write-string prompt)
  8. (write-string ": ")
  9. (read-line))
  10. ; make sure we can use the sqlite3 connection
  11. (if sqlite3-available?
  12. (write-string "Adding new proposal to the database.")
  13. (error "Sqlite3 library not available."))
  14. ; open the database file
  15. (define conn (sqlite3-connect #:database dbloc))
  16. ; user inputs proposal data
  17. (define proptype (getinput "Proposal type"))
  18. (define org (getinput "Submitting organization"))
  19. (define solic (getinput "Solitation/call"))
  20. (define tele (getinput "Telescope"))
  21. (define title (getinput "Proposal title"))
  22. (define pi (getinput "PI"))
  23. (define coi (getinput "CoIs"))
  24. ; assume all these proposals are submitted, don't ask the user
  25. (define status "submitted")
  26. (define submitdate (getinput "Submit date"))
  27. (define oID (getinput "Organization's proposal ID"))
  28. ; do the INSERT into the Sqlite database
  29. (query-exec conn "INSERT INTO proposals (type, organization, solicitation, telescope, PI, title, CoI, status, submitdate, orgpropID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
  30. proptype org solic tele pi title coi status submitdate oID)
  31. ; close the databse
  32. (disconnect conn)