update_proposals.rkt 1.2 KB

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