diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2018-12-30 11:49:29 -0500 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2018-12-30 11:55:15 -0500 |
| commit | 961b362ab35f5900cd3b3ab90a9a4082fbfdcb3c (patch) | |
| tree | 736a16ed2e7a403d8033db42dce168ff530dde00 /script.py | |
| parent | fb24d087de5d0ab893887b48936b12645aa6dc57 (diff) | |
| download | famille-flask-961b362ab35f5900cd3b3ab90a9a4082fbfdcb3c.tar.gz | |
script to update authdb
Diffstat (limited to 'script.py')
| -rw-r--r-- | script.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/script.py b/script.py new file mode 100644 index 0000000..fd60a3c --- /dev/null +++ b/script.py @@ -0,0 +1,16 @@ +import sqlite3 +import psycopg2 + +conn = sqlite3.connect("/home/http/famille/famille.db", + detect_types=sqlite3.PARSE_DECLTYPES) +conn.row_factory = sqlite3.Row +conn.execute("PRAGMA foreign_keys=ON") +cur = conn.execute("SELECT id, user_name, password from users") + +authdb = psycopg2.connect("postgres://auth_master@localhost/authdb") +sql_str = "INSERT INTO users(id, name, password) VALUES(%s, %s, %s)" +with authdb.cursor() as c: + for id, name, password in cur: + c.execute(sql_str, (id, name, password)) +authdb.commit() +authdb.close() |
