最近我使用python模块数据集来操作和存储信息。结果,我有一组 sqlite 数据库,比如说 file1.db、file2.db 等等。此外,每个数据库都包含相同的表。
使用数据集,我可以使用代码轻松连接和检查数据库:
>>> db1 = dataset.connect('sqlite:////path/file1.db')
>>> table1 = db1[u'tweet']
假设我想将数据库分隔在许多文件中,用数据集检查所有数据库的最佳方法是什么?
我正在寻找更好的东西:
>>> db1 = dataset.connect('sqlite:////path/file1.db')
>>> db2 = dataset.connect('sqlite:////path/file2.db')
>>> tables = [db1[u'tweet'],db2[u'tweet']]
>>> for table in tables:
for tweet in table:
print(tweet['text'])