Selaa lähdekoodia

put database location into a config file

George C. Privon 6 vuotta sitten
vanhempi
commit
bd086a2093
3 muutettua tiedostoa jossa 13 lisäystä ja 2 poistoa
  1. 3 0
      .gitignore
  2. 5 0
      config.rkt.example
  3. 5 2
      update_proposals.rkt

+ 3 - 0
.gitignore

@@ -13,3 +13,6 @@ compiled/
 
 # Dependency tracking files
 *.dep
+
+# fille configuration file
+config.rkt

+ 5 - 0
config.rkt.example

@@ -0,0 +1,5 @@
+#lang racket
+
+(provide dbloc)
+
+(define dbloc "/path/to/database")

+ 5 - 2
update_proposals.rkt

@@ -2,6 +2,9 @@
 
 (require db)
 
+; load configuration file
+(require (file "config.rkt"))
+
 ; set up a condensed prompt for getting information
 (define (getinput prompt)
   (write-string prompt)
@@ -10,12 +13,12 @@
 
 ; make sure we can use the sqlite3 connection
 (if sqlite3-available?
-    "Adding new proposal to the database."
+    (write-string "Adding new proposal to the database.")
     (error "Sqlite3 library not available."))
 
 ; open the database file
 (define conn (sqlite3-connect #:database
-              "/home/george/work/proposals/proposals.sqlite"))
+              dbloc))
 
 ; user inputs proposal data
 (define proptype (getinput "Proposal type"))