Android Question SQlite large query from file

hub73

Active Member
Licensed User
Longtime User
Hi !

I'm searching a way to execute INSERT big query inside my SQLite database.

As i have a lot of items, could i 'load' the query from a text file ? So could you help me with the syntax...

It's a nightmare to edit the query inside the IDE. (it was a Mysql query)

Dim Query as String

Query = " " & <--- data from the file.txt --> & " "

and my file.txt :

insert into t_big_table values ( ... a lot of ...)

Many thanks
 

KMatle

Expert
Licensed User
Longtime User
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
If your query's syntax is compatible with sqlite (I see few reasons why it's not), then you can just begin a transaction (as Erel previously suggested) and then execute a nonQuery containing the file.readString(your query's txt file). If for some reason your query is not exactly suitable for such action, you can always split your txt file into many rows and pass them to sqlite using a loop.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…