这段代码比较笼统,但也许可以帮助您:
import sqlite3new_db = sqlite3.connect(':memory:') # create a memory databaseold_db = sqlite3.connect('test.db')query = "".join(line for line in old_db.iterdump())# Dump old database in the new one. new_db.executescript(query)
编辑: 为获取您的指定表,您可以仅在for循环中更改,如下所示:
name_table = "test_table" # name of the table that you want to get.for line in old_db.iterdump(): if name_table in line: query = line break
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)