-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocManSQLFunc.py
More file actions
37 lines (33 loc) · 972 Bytes
/
DocManSQLFunc.py
File metadata and controls
37 lines (33 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sqlite3 as lite
def MergeDocMan():
'''
Voeg records uit een andere Db toe aan de productie Db
- voer een query uit - resulaat is een list of lists
wordt via executemany ingelezen in de productie Db, unieke sleutel op pad.
DocMan.db bevat de laatste bestanden
DocMan(Laatste) bevat is een restore.
'''
con = lite.connect('DocMan(Laatste).db')
con2 = lite.connect('DocMan.db')
# Gebruik de dictionary om velden te selecteren, daarmee kan de standaard print(row) niet werken. Geeft dan alleen de memory locatie.
#con.row_factory = lite.Row
cur = con.cursor()
cur2 = con2.cursor()
sql="""SELECT * FROM DocMan;"""
try:
cur.execute(sql)
rows = cur.fetchall()
print (rows)
cur2.executemany("INSERT INTO DocMan VALUES(?, ?, ?, ?, ?, ?)", rows)
con2.commit()
for row in rows:
print(row)
# for i in row:
# print(i)
except lite.Error as e:
print (e.args[0])
if con:
con.close()
con2.close()
print('DB Closed')
MergeDocMan()