开发者

Export sqlite DB to csv issue

开发者 https://www.devze.com 2023-01-29 00:46 出处:网络
When I used db.execSQL(.mode csv) in J开发者_如何学JAVAava code, it generates error in logcat. /AndroidRuntime( 1363): FATAL EXCEPTION: main

When I used db.execSQL(.mode csv) in J开发者_如何学JAVAava code, it generates error in logcat.

/AndroidRuntime( 1363): FATAL EXCEPTION: main
/AndroidRuntime( 1363): android.database.sqlite.SQLiteException: near ".": syntax error: .mode csv

but if I issue the same in sqlite console, it works. I also cannot set separator in java code.

sqlite> .mode csv
.mode csv
sqlite> .separator ,
.separator ,
sqlite>

Can anyone share experience with me or what is correct approach ? I will be appreciated if codes are provided.

Thanks !!


The .mode csv syntax and other dot-commands are proper to the sqlite shell, which is a specific program built on SQLite.

What you can do in java is just use the Database engine, not the .mode, .help, .quit or .separator from another program.

However you can find the source code for the SQLite shell here.

fossil clone http://www.sqlite.org/src _my_sqlite_repository
mkdir SQLite_source
cd SQLite_source
fossil open ../_my_sqlite_repository

Then you can download the latest updates with fossil update trunk and see the source code at src/shell.c. You will probably notice that this is the only piece of source code around that includes additional libraries.

0

精彩评论

暂无评论...
验证码 换一张
取 消