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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

3 replies 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. Required fields are marked *