SQLite too many terms in SELECT

In my SQLite databese SQL query, I have an INSERT INTO statement followed by about 600 ('data1'), ('data2') ... tags generated by the code.

After db.exec (sql) I got this error: "there are too many terms in compound SELECT (code1), while compiling INSERT INTO .."

Is there any way to increase this limit?

+6
source share
1 answer

SQLITE_MAX_COMPOUND_SELECT limit cannot be raised at run time ,

So, you need to divide your inserts into batches of 500 rows. This will be more efficient than inserting one row for each query. For instance,

 BEGIN TRANSACTION INSERT INTO tablename (data1,data2) VALUES ("data1","data2") INSERT INTO tablename (data1,data2) VALUES ("data1","data2") INSERT INTO tablename (data1,data2) VALUES ("data1","data2") ... END TRANSACTION 

Also see Insert multiple rows in SQLite

+7
source

Source: https://habr.com/ru/post/973690/


All Articles