最後活躍 1729506879

chlorine's Avatar chlorine 已修改 1729506877. 還原成這個修訂版本

1 file changed, 20 insertions

memos_migr.py(檔案已創建)

@@ -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()
上一頁 下一頁