about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--README.org10
-rwxr-xr-xdump.scm37
2 files changed, 24 insertions, 23 deletions
diff --git a/README.org b/README.org
index fbc5705..b688d3e 100644
--- a/README.org
+++ b/README.org
@@ -22,15 +22,15 @@ brackets with the appropriate values.
    (port . <port-here>))
 #+END_SRC
 
-Then, to dump the database, run
+Then, to dump the database to ~/data/dump, run
 
 #+BEGIN_SRC shell
-  $ ./pre-inst-env ./dump.scm
+  $ ./pre-inst-env ./dump.scm conn.scm ~/data/dump
 #+END_SRC
 
-The database will be dumped to ~/data/dump/. Make sure there is enough
-free space! It's best to dump the database on penguin2 where disk
-space and bandwidth are not significant constraints.
+Make sure there is enough free space! It's best to dump the database
+on penguin2 where disk space and bandwidth are not significant
+constraints.
 
 * Contributing
 
diff --git a/dump.scm b/dump.scm
index 112cc1a..30cb8dd 100755
--- a/dump.scm
+++ b/dump.scm
@@ -1,7 +1,8 @@
 #! /usr/bin/env guile
 !#
 
-(use-modules (rnrs io ports)
+(use-modules (rnrs programs)
+             (rnrs io ports)
              (srfi srfi-1)
              (srfi srfi-26)
              (ice-9 match)
@@ -13,25 +14,24 @@
 
 ;;; GeneNetwork database connection parameters and dump path
 
+(define %connection-settings
+  (call-with-input-file (list-ref (command-line) 0)
+    read))
+
 (define (call-with-genenetwork-database proc)
-  (let ((connection-settings (call-with-input-file "conn.scm" read)))
-    (call-with-database "mysql" (string-join
-                                 (list (assq-ref connection-settings 'username)
-                                       (assq-ref connection-settings 'password)
-                                       (assq-ref connection-settings 'database)
-                                       "tcp"
-                                       (assq-ref connection-settings 'host)
-                                       (number->string
-                                        (assq-ref connection-settings 'port)))
-                                 ":")
-                        proc)))
-
-(define %database-name
-  (assq-ref (call-with-input-file "conn.scm" read)
-            'database))
+  (call-with-database "mysql" (string-join
+                               (list (assq-ref %connection-settings 'username)
+                                     (assq-ref %connection-settings 'password)
+                                     (assq-ref %connection-settings 'database)
+                                     "tcp"
+                                     (assq-ref %connection-settings 'host)
+                                     (number->string
+                                      (assq-ref %connection-settings 'port)))
+                               ":")
+                      proc))
 
 (define %dump-directory
-  (string-append (getenv "HOME") "/data/dump"))
+  (list-ref (command-line) 1))
 
 (define (call-with-dump-file filename proc)
   (let ((absolute-path (string-append %dump-directory filename)))
@@ -717,7 +717,8 @@ is a <table> object."
                 (select-query ((information_schema.tables table_name)
                                (information_schema.tables data_length))
                               (information_schema.tables)
-                              (format #f "WHERE table_schema = '~a'" %database-name)))))
+                              (format #f "WHERE table_schema = '~a'"
+                                      (assq-ref %connection-settings 'database))))))
 
 (define (dump-schema db)
   (let ((tables (tables db)))