In my application I need to import data from csv files into sqlite database.
For working with sqlite I use FMDB library, because it is easy to use:)
Help me please, how to import data from csv file to a table?
I have a table created, corresponding to a table in csv file, so it should be ease to import.
I looked at solutions around the internet, and found terminal commands for sqlite such as
".mode csv"
".separator ';'"
".import mycsvfile.csv mytablename"
But when I try to execute this sql statements in FMDB, it fails..
My source code:
[db beginTransaction];
NSString *query1 = @".mode csv";
NSString *query2 = @".separator ';'";
NSString *query3 = @".import mycsvfile.csv mytablename";
BOOL result = [db executeUpdate:query];
result = [db executeQuery:query2];
result = [db executeQuery:query3];
[db commit];
Here after stepping over BOOL result = [db executeUpdate:query]; result equals to FALSE, indicating that it was error..
After turning on logging in FMDB, it says "incorrect syntax" in my queries.
But why does this statements work in OS X's sqlite?
Note: when i am trying to execute this commands in OS X terminal, in sqlite3, all works correctly.