如何处理从sqlite2到sqlite3的UTF-8字符迁移
时间:2020-03-06 14:22:41 来源:igfitidea点击:
尝试简单的方法:
sqlite2 mydb.db .dump | sqlite3 mydb-new.db
我收到此错误:
SQL error near line 84802: no such column: D
在该行中,脚本是这样的:
INSERT INTO vehiculo VALUES(127548,'21K0065217',?,'PA007808',65217,279,1989,3,468,'1998-07-30 00:00:00.000000','14/697/98-07',2,'',1);
我的猜测是"?"没有引号是问题。
任何的想法?
PD:我现在在Windows下,我想使用命令行以便可以自动化(此过程将由服务器每天进行)。
解决方案
我试图在没有Windows干预的情况下做到这一点:
*by calling sqlite2 on old.db, and send the dump directly to a file *and then call sqlite3 on new.db and loading the dump directly from the file.
以防万一Windows弄乱了命令行上的字符。
结果相同。
好吧,没人回答...最后,我最终修改了我的原始脚本(首先创建了sqlite2数据库的脚本)以直接在sqlite3中创建数据库。
我认为一个大的字符串处理脚本(之所以如此大是因为mi数据库的大小分别为800mb和200mb),但是直接生成数据库对我来说更容易。
只需使用sqlite3二进制CLI打开v2数据库,然后将其保存。数据库文件将透明地迁移到v3.
$ sqlite3 v2database.db sqlite> .quit $
注意:我们可能需要在退出之前插入/删除一行以强制进行更新。
Simply open the v2 database with the sqlite3 binary CLI, and then save it. The database file will be transparently migrated to v3.
它不起作用。
$sqlite3 db2 SQLite version 3.6.16 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> .tables Error: file is encrypted or is not a database sqlite> .q
而且文件没有更改(显然sqlite3无法读取)。我认为最初的问题是sqlite2中的错误。