update_proposals.rkt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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
  16. dbloc))
  17. ; user inputs proposal data
  18. (define proptype (getinput "Proposal type"))
  19. (define org (getinput "Submitting organization"))
  20. (define solic (getinput "Solitation/call"))
  21. (define tele (getinput "Telescope"))
  22. (define title (getinput "Proposal title"))
  23. (define pi (getinput "PI"))
  24. (define coi (getinput "CoIs"))
  25. ; assume all these proposals are submitted, don't ask the user
  26. (define status "submitted")
  27. (define submitdate (getinput "Submit date"))
  28. (define oID (getinput "Organization's proposal ID"))
  29. ; do the INSERT into the Sqlite database
  30. (query-exec conn "INSERT INTO proposals (type, organization, solicitation, telescope, PI, title, CoI, status, submitdate, orgpropID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
  31. proptype org solic tele pi title coi status submitdate oID)
  32. ; close the databse
  33. (disconnect conn)