aboutsummaryrefslogtreecommitdiffstats
path: root/script.py
blob: fd60a3cc0368f57392c54e0eb71f864a67dae06a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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()