我是Python新手。我试图比较两个具有相同模式的sqlite数据库。两个数据库中的表结构也相同,但数据不同。我想从两个数据库中提取两个表中的行,这些行在db1.fdetail或{}中都不存在
DB1 -
Table - fdetailid name key
1 A k1
2 B K2
3 C K3
DB2 -
Table - fdetail
^{pr2}$
预期产量id name keyid
1 B k2
2 C K3
3 D K4
4 E K5
5 F K6
我的代码是import sqlite3
db1 = r"C:\Users\X\Documents\sqlitedb\db1.db"
db2 = r"C:\Users\X\Documents\sqlitedb\db2.db"
tblCmp = "SELECT * FROM fdetail order by id"
conn1 = sqlite3.connect(db1)
conn2 = sqlite3.connect(db2)
cursor1 = conn1.cursor()
result1 = cursor1.execute(tblCmp)
res1 = result1.fetchall()
cursor2 = conn2.cursor()
result2 = cursor2.execute(tblCmp)
res2 = result2.fetchall()
所以我有两个列表res1和{}。如何比较基于列Keyid的列表。在
非常感谢任何帮助。在