0
votes

I'm trying to import .sqlite file to sqlite3 im using windows 8 pc, It's throwing an error of

expected 5 rows found 1-rest filled with null

even my table columns are fine.

can anyone please help me.

thank you in advance.

3
How do you try to import the file? (Usually .sqlite is already the database format, not SQL suitable for import.) Can you show the content of your .sqlite file? - Thomas
if I do .read <filename>.sqlite it's reading but some unwanted characters also coming with this - harishkumar329
That does not look like SQL but more like the binary storage format of sqlite. In that case you don't have to import it, but can use it as a database directly. - Thomas
ya thanks a lot, can you please help me to use this directly. - harishkumar329

3 Answers

2
votes

I think you can try this method. So you don't have to import/export via third-party files such as csv or any additional software. I plan to do this method to periodically copy aquired data in a RAMDRIVE-placed database to the SD-Card. Of course sqlite3 must be able to load your database in your case.

ATTACH DATABASE 'foo.sqlite' AS 'foo';
.databases

INSERT OR REPLACE INTO 'main.mytable' SELECT * FROM 'foo.mytable';
DETACH DATABASE 'foo';
.databases

check here for ATTACH syntax and here for more INSERT variations.

1
votes

What you can do is use a third party tool called SQLite Database Browser (http://sourceforge.net/projects/sqlitebrowser).

Using the sqlite browser, open your database in old format (.sqlite) and then click File -> Export -> Database to SQL file.

Now, close the database. Create a new database using SQLite Browser (it automatically generates the database in the new SQLite3 format). Once a database is created, use the File -> Import -> Database to SQL file into the new database in SQLite3 format.

1
votes

You use the PHP sqlite API to use an .sqlite database.

See http://php.net/manual/en/book.sqlite.php

In general you supply the path to your .sqlite file in the sqlite_open() call, see for an example the manual page of sqlite_open:

http://www.php.net/manual/en/function.sqlite-open.php