2008-09-18 42 views
1

嘗試簡單的方法:如何處理UTF-8字符sqlite2到SQLITE3遷移

sqlite2 mydb.db .dump | sqlite3 mydb-new.db

我得到這個錯誤:

SQL error near line 84802: no such column: Ð

在該行的腳本是這樣的:

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下,我想使用命令行,以便它可以自動化(此過程將由服務器每天完成)。

回答

1

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中的一個錯誤。

+0

我遇到了這個問題太......錯誤:文件被加密或不是數據庫的任何解決方案? – 2010-03-16 15:06:06

0

我試圖做到這一點沒有窗戶的干預:

*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的命令行的字符搞亂。

相同的結果。

1

沒有人回答......最後,我最終修改了我的原始腳本(創建sqlite2數據庫的那個),直接在sqlite3中創建數據庫。

我認爲一個大的字符串處理腳本(因爲mi數據庫每個都是800mb和200mb很大)可以完成這項工作,但直接生成數據庫對我來說更容易。

2

只需使用sqlite3二進制CLI打開v2數據庫,然後保存它。數據庫文件將透明地遷移到v3。

$ sqlite3 v2database.db 
sqlite> .quit 
$ 

注意:在退出強制更新之前,您可能需要插入/刪除一行。

+1

真的那麼簡單嗎?我手邊沒有數據庫了soo我無法真正測試它,但是我儘快拿到一些測試數據,我會試試它 – levhita 2009-02-20 20:06:57