Categories
Python Answers

How to fix ProgrammingError: SQLite objects created in a thread can only be used in that same thread with Python SQLite3?

Spread the love

Sometimes, we want to fix ProgrammingError: SQLite objects created in a thread can only be used in that same thread with Python SQLite3

In this article, we’ll look at how to fix ProgrammingError: SQLite objects created in a thread can only be used in that same thread with Python SQLite3.

How to fix ProgrammingError: SQLite objects created in a thread can only be used in that same thread with Python SQLite3?

To fix ProgrammingError: SQLite objects created in a thread can only be used in that same thread with Python SQLite3, we can call sqlite3.connect with check_same_thread set to False.

For instance, we wrikte

conn = sqlite3.connect('your.db', check_same_thread=False)

to call sqlite3.connect with the check_same_thread set to False so that SQLite objects created in any thread can be used in any other thread.

Conclusion

To fix ProgrammingError: SQLite objects created in a thread can only be used in that same thread with Python SQLite3, we can call sqlite3.connect with check_same_thread set to False.

One reply on “How to fix ProgrammingError: SQLite objects created in a thread can only be used in that same thread with Python SQLite3?”

Thanks for this post🙌 , it has been useful. I was looking for this solution, and this website has been the unique source of correct information.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.