diff options
Diffstat (limited to 'add-user.scm')
-rw-r--r-- | add-user.scm | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/add-user.scm b/add-user.scm new file mode 100644 index 0000000..9799bf5 --- /dev/null +++ b/add-user.scm @@ -0,0 +1,28 @@ +(import + scheme (chicken base) + (chicken process-context) + sqlite3 + crypt + srfi-1 +) + +(define params (argv)) +(define username (second params)) +(define password (third params)) +(define password-hash (crypt password)) + +(define db (open-database (or (get-environment-variable "DB_FILE") "/tmp/54itter.db"))) + +(execute db "CREATE TABLE IF NOT EXISTS users ( + user_id TEXT PRIMARY KEY, + pw_hash TEXT, + created_at DATETIME default current_timestamp + )") + +(execute db "INSERT INTO users + (user_id, pw_hash) + VALUES (?, ?)" + username password-hash) +(finalize! db) + +(print "Created user " username) |