mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-09-17 12:13:35 +00:00
Fix multithreading issues for older SQLite versions (#1442)
* Update sql.py * Parametrize check_same_thread Co-authored-by: Malte Pietsch <malte.pietsch@deepset.ai>
This commit is contained in:
parent
74d052277d
commit
bff90c19d5
@ -74,7 +74,8 @@ class SQLDocumentStore(BaseDocumentStore):
|
|||||||
url: str = "sqlite://",
|
url: str = "sqlite://",
|
||||||
index: str = "document",
|
index: str = "document",
|
||||||
label_index: str = "label",
|
label_index: str = "label",
|
||||||
duplicate_documents: str = "overwrite"
|
duplicate_documents: str = "overwrite",
|
||||||
|
check_same_thread: bool = False
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
An SQL backed DocumentStore. Currently supports SQLite, PostgreSQL and MySQL backends.
|
An SQL backed DocumentStore. Currently supports SQLite, PostgreSQL and MySQL backends.
|
||||||
@ -89,14 +90,15 @@ class SQLDocumentStore(BaseDocumentStore):
|
|||||||
overwrite: Update any existing documents with the same ID when adding documents.
|
overwrite: Update any existing documents with the same ID when adding documents.
|
||||||
fail: an error is raised if the document ID of the document being added already
|
fail: an error is raised if the document ID of the document being added already
|
||||||
exists.
|
exists.
|
||||||
|
:param check_same_thread: Set to False to mitigate multithreading issues in older SQLite versions (see https://docs.sqlalchemy.org/en/14/dialects/sqlite.html?highlight=check_same_thread#threading-pooling-behavior)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# save init parameters to enable export of component config as YAML
|
# save init parameters to enable export of component config as YAML
|
||||||
self.set_config(
|
self.set_config(
|
||||||
url=url, index=index, label_index=label_index, duplicate_documents=duplicate_documents
|
url=url, index=index, label_index=label_index, duplicate_documents=duplicate_documents, check_same_thread=check_same_thread
|
||||||
)
|
)
|
||||||
|
|
||||||
engine = create_engine(url)
|
engine = create_engine(url,connect_args={'check_same_thread': check_same_thread})
|
||||||
ORMBase.metadata.create_all(engine)
|
ORMBase.metadata.create_all(engine)
|
||||||
Session = sessionmaker(bind=engine)
|
Session = sessionmaker(bind=engine)
|
||||||
self.session = Session()
|
self.session = Session()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user