I have a script functions.py that contains functions for all the database processing in sql, and another one that imports functions.py and is supposed to call something like functions.get_all_entries_in_database(). However, I always get this error:
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/A76B1CFC-263B-4F7C-8D73-F7A0548010E8/Pythonista3/Documents/Codes/Audio/Main.py", line 52, in change_playing_mode_action
modes = manager.get_playing_modes(id)
File "/private/var/mobile/Containers/Shared/AppGroup/A76B1CFC-263B-4F7C-8D73-F7A0548010E8/Pythonista3/Documents/Codes/Audio/db_lib.py", line 144, in get_playing_modes
modes = c.execute('SELECT %s FROM playing_mode ORDER BY id'%keywords).fetchall()
sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 6163689472 and this is thread id 4315310976
salite3.threadsafety doesn’t chance anything...
@Drizzel do you specify
sql_connect = sqlite3.connect(db_file,check_same_thread=False)
@cvp nope, I didn’t. Thanks a lot :)
@Drizzel, would still recommend understanding which thread is used to initialize the connection, and which thread to make sql queries, especially updates.
@mikael I got a similar problem in a script where an ui.in_background def did a sql process and an in_main_thread def did another one...Threads were defined due to ui/modal problems