diff options
author | Arun Isaac | 2022-03-10 17:16:52 +0530 |
---|---|---|
committer | Arun Isaac | 2022-03-10 17:46:38 +0530 |
commit | e1c3360f04830c56468ca6210361fe794ea3c987 (patch) | |
tree | 3f5c826bc462937276f6b0acd1f2ab5da4a5a3af | |
parent | 900c4df8e336a453446150528daeaad77b81f020 (diff) | |
download | gn-transform-databases-e1c3360f04830c56468ca6210361fe794ea3c987.tar.gz |
Accept connection parameters and dump directory as arguments.
* dump.scm: Import (rnrs programs).
(%connection-settings): New variable.
(call-with-database): Use %connection-settings.
(%database-name): Delete variable.
(%dump-directory): Set from command-line arguments.
(dump-data-table): Use %connection-settings instead of %database-name.
* README.org (Using): Add command-line arguments to usage
instructions.
-rw-r--r-- | README.org | 10 | ||||
-rwxr-xr-x | dump.scm | 37 |
2 files changed, 24 insertions, 23 deletions
@@ -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 @@ -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))) |