chlorine revised this gist . Go to revision
1 file changed, 20 insertions
memos_migr.py(file created)
@@ -0,0 +1,20 @@ | |||
1 | + | import sqlite3 | |
2 | + | ||
3 | + | conn_source = sqlite3.connect('db/source.db') | |
4 | + | conn_target = sqlite3.connect('db/memos_prod.db') | |
5 | + | ||
6 | + | cur_source = conn_source.cursor() | |
7 | + | cur_target = conn_target.cursor() | |
8 | + | ||
9 | + | #? change here | |
10 | + | cur_source.execute('SELECT * FROM tag') | |
11 | + | rows = cur_source.fetchall() | |
12 | + | ||
13 | + | #? change here | |
14 | + | for row in rows: | |
15 | + | cur_target.execute('INSERT INTO tag VALUES (?, ?)', row) # 假设表有两列 | |
16 | + | ||
17 | + | conn_target.commit() | |
18 | + | ||
19 | + | conn_source.close() | |
20 | + | conn_target.close() |
Newer
Older