iphone - Importing data from .csv file to the sqlite database in IOS. FMDB -


in application need import data csv files sqlite database.

for working sqlite use fmdb library, because easy use:)

help me please, how import data csv file table?

i have table created, corresponding table in csv file, should ease import.

i looked @ solutions around internet, , found terminal commands sqlite such

".mode csv" ".separator ';'" ".import mycsvfile.csv mytablename" 

but when try execute sql statements in fmdb, 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 on bool result = [db executeupdate:query]; result equals false, indicating error..

after turning on logging in fmdb, says "incorrect syntax" in queries.

but why statements work in os x's sqlite?

note: when trying execute commands in os x terminal, in sqlite3, works correctly.

the .import command using isn't part of sqlite itself, rather part of sqlite cli (command line interface) shell. docs tool here. can download source code cli tool (file shell.c, think) part of sqlite distribution sqlite.org.

if want import csv data in ios app sqlite you'll need manual parsing of csv file yourself, inserting data tables in sqlite database.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -