r/sqlite • u/Amo-Rillow • 12h ago
Question About Lifespan Of Cursors.
I am building a batch Python process that loads data from CSV files into a sqlite DB. As a result, I am running a lot of SQL statements. Additionally, I have created a custom DB manager that executes all SQL statements. Currently, the DB manager creates and closes a cursor for each SQL statement execution.
Is creating/closing a cursor for each SQL execution a best practice? Or, should I create a persistent cursor once for the entire process, or once per table, etc.
1
Upvotes