본문 바로가기

컴터 때찌/Error

[Error - Python2.7] sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was created in thread

[상황] 

python2.7에서 sqlite3를 이용해서 프로그래밍 하고 있는데 잘 돌아가던 프로그램이 thread를 사용하니 아래의 에러가 남


[에러]

sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 3820 and this is thread id 1700


[해결] 


db = sqlite3.connect("test.db")    <->   db = sqlite3.connect("test.db",check_same_thread=False)


[REF]

https://stackoverflow.com/questions/393554/python-sqlite3-and-concurrency