Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

How to increase SQLITE_MAX_VARIABLE_NUMBER at compilation-time?

I'm using Python and the Peewee module to manage a Sqlite3 database. In my program I need to do bulk inserts otherwise the addition of new rows to my traffic table takes to much time, however, I already managed to insert multiple rows at once, but now I am in the necessity to increase the SQLITE_MAX_VARIABLE_NUMBER whose default value is 999, in order to reduce the execution time.

I'm adding around 100000 entries to the table but it takes around 40 seconds to finish.

Any idea of how to modify this limit?

Thanks

1 Answer

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

It is not possible to change SQLITE_MAX_VARIABLE_NUMBER for sqlite3 program unless you change source files and re-compile sqlite3 program your self, see best answer here:

http://stackoverflow.com/questions/15312590/what-is-the-limit-of-sql-variables-one-can-specify-in-a-single-execsql-query

But If you use peewee, here is how guy changes it

http://stackoverflow.com/questions/35616602/peewee-operationalerror-too-many-sql-variables-on-upsert-of-only-150-rows-8-c

And looking from documentation as I understand correctly you can change SQLITE_MAX_VARIABLE_NUMBER directly (check Note in documentation below):

http://docs.peewee-orm.com/en/latest/peewee/querying.html#bulk-inserts

That's all I could get. I'm not a very good Python user, to check all of these, but hopefully those links could be of some help.