我正在尝试在 Windows 上使用 Python 将 SQLite 2 文件转换为 SQLite3。在 Linux 上,我只需将转储从管道sqlite
传输到sqlite3
:
os.system("sqlite db.sqlite .dump | sqlite3 db3.sqlite")
在 Windows 上,我没有这种方便的方法来传输转储。这就是我正在做的事情:
sqlite_dump = os.popen('sqlite %s .dump' % sqlite_db).read()
open(sqlite_dump_file, "w").write(sqlite_dump)
os.system("del %s" % sqlite_db)
os.system("sqlite3 -init %s %s" % (sqlite_db,
sqlite_dump_file))
这行得通,但它让我有一个sqlite3
提示。我已经尝试过-bail
切换并在 SQLite 转储的末尾添加了 `"\n.quit\n",但无济于事。
我能做些什么?