Skip to content

SQLite error triggered by long time connection #45

@SilverNebula

Description

@SilverNebula

Hello,
I've encountered an SQLite error while developing an interactive program using the pyensembl package. My program listens to user queries and looks up data from the genome database using Pyensembl. If the queries come in separately and in a long time, which could cause the database connection to become idle, it throws an error:

Error: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140376670246656 and this is thread id 140375293421312.

I tried to fix this by change datacache/database.py line 38:
from
self.connection = sqlite3.connect(path)
to
self.connection = sqlite3.connect(path,check_same_thread=False)

(https://github.com/SilverNebula/datacache/blob/0a0bd6cd3822f291c966b886328e85dfc7a7fcba/datacache/database.py)

This solution resolves the issue, but I'm not sure about if other problems may arise as a result. Could you please check the problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions