Skip to content

Commit 9047fee

Browse files
committed
Set connect_args={"check_same_thread": False} to avoid "not the owner thread" warnings from sqlite.
1 parent b61630c commit 9047fee

File tree

33 files changed

+190
-31
lines changed

33 files changed

+190
-31
lines changed

app/ch09_sqlalchemy/final/.idea/.name

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/ch09_sqlalchemy/final/.idea/flask ch09_sqlalchemy - final.iml

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/ch09_sqlalchemy/final/pypi_org/data/db_session.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ def global_init(db_file: str):
1818
conn_str = 'sqlite:///' + db_file.strip()
1919
print("Connecting to DB with {}".format(conn_str))
2020

21-
engine = sa.create_engine(conn_str, echo=False)
21+
# Adding check_same_thread = False after the recording. This can be an issue about
22+
# creating / owner thread when cleaning up sessions, etc. This is a sqlite restriction
23+
# that we probably don't care about in this example.
24+
engine = sa.create_engine(conn_str, echo=False, connect_args={"check_same_thread": False})
2225
factory = orm.sessionmaker(bind=engine)
2326

2427
# noinspection PyUnresolvedReferences

app/ch10_using_sqlachemy/final/.idea/.name

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/ch10_using_sqlachemy/final/.idea/inspectionProfiles/Project_Default.xml

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/ch10_using_sqlachemy/final/.idea/modules.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/ch10_using_sqlachemy/final/pypi_org/data/db_session.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ def global_init(db_file: str):
1919
conn_str = 'sqlite:///' + db_file.strip()
2020
print("Connecting to DB with {}".format(conn_str))
2121

22-
engine = sa.create_engine(conn_str, echo=False)
22+
# Adding check_same_thread = False after the recording. This can be an issue about
23+
# creating / owner thread when cleaning up sessions, etc. This is a sqlite restriction
24+
# that we probably don't care about in this example.
25+
engine = sa.create_engine(conn_str, echo=False, connect_args={"check_same_thread": False})
2326
__factory = orm.sessionmaker(bind=engine)
2427

2528
# noinspection PyUnresolvedReferences

app/ch10_using_sqlachemy/starter/.idea/flask ch10_using_sqlachemy - starter.iml

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/ch10_using_sqlachemy/starter/pypi_org/data/db_session.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ def global_init(db_file: str):
1818
conn_str = 'sqlite:///' + db_file.strip()
1919
print("Connecting to DB with {}".format(conn_str))
2020

21-
engine = sa.create_engine(conn_str, echo=False)
21+
# Adding check_same_thread = False after the recording. This can be an issue about
22+
# creating / owner thread when cleaning up sessions, etc. This is a sqlite restriction
23+
# that we probably don't care about in this example.
24+
engine = sa.create_engine(conn_str, echo=False, connect_args={"check_same_thread": False})
2225
factory = orm.sessionmaker(bind=engine)
2326

2427
# noinspection PyUnresolvedReferences

0 commit comments

Comments
 (0)