On 7/08/2009 1:21 PM, aerende wrote:
> I'm trying to take a CSV file and create a sqlite3 database for the iPhone. 
> The CSV file has 33K entries and is 2 MB.  The problem I am having is that
> only about 1/10 of the database file gets written into the sqlite3 database.
> 
> I first translated the CSV file into SQL commands using the terminal-based
> verison of sqlite3:
> 
>     % sqlite3
>     sqlite> .mode csv
>     sqlite> create table mydatabasetable (ITEM_ID INTEGER PRIMARY KEY,
> FIELDA TEXT, FIELDB TEXT);
>     sqlite> .import myfile.csv mydatabasetable

Were there any error messages from that step?

If at this stage you do

    select count(*) from mydatabasetable;

what is the result? If it's not the full 33K, which records are being 
left out?

>     sqlite> .output mydatabasetable.sql

The .output command specifies what file any output will be sent to. It 
doesn't actually generate any output itself. Perhaps you are missing a 
.dump command and a quit command -- it's always a good idea to 
copy/paste actual output into your mail client, rather than re-typing it 
from memory.

> Then I tried to create a sqlite3 database from the sql file:
> 
>     % sqlite3 mydatabasetable.sqlite < mydatabasetable.sql

Any errors from this step? What does select count(*) give you?

> 
> When I read in mydatabasetable.sqlite into a sqlite3 database,

What does that mean? A third step? If mydatabasetable.sqlite is not 
already a sqlite3 database, the previous steps have run amok somehow.

> only the
> first 3400 entries out of 33,000 are in the database even though
> mydatabasetable.sql has 33,000 unique insert commands.

In which database?

> Am I following the correct approach to write out an sqlite database? 

Dunno why you are doing it in two (three?) steps; the CSV import should 
be all you need.

> Is
> there some default database filesize limit that I need to set?  Does anyone
> know why only the first 3400 entries show up in the database?

It would help very much if you said what version of SQLite you are 
running and what platform you are running it on.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to