
import sqlite3from io import StringIOdef init_sqlite_db(app): # Read database to tempfile con = sqlite3.connect(app.config['SQLITE_DATAbase']) tempfile = StringIO() for line in con.iterdump(): tempfile.write('%sn' % line) con.close() tempfile.seek(0) # Create a database in memory and import from tempfile app.sqlite = sqlite3.connect(":memory:") app.sqlite.cursor().executescript(tempfile.read()) app.sqlite.commit() app.sqlite.row_factory = sqlite3.Row欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)