这段代码比较笼统,但也许可以帮助您:
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


![如何在python中将sqlite表从磁盘数据库复制到内存数据库?[重复] 如何在python中将sqlite表从磁盘数据库复制到内存数据库?[重复]](http://www.mshxw.com/aiimages/31/626358.png)
