diff --git a/pykern/sql_db.py b/pykern/sql_db.py index c66902af..4c308776 100644 --- a/pykern/sql_db.py +++ b/pykern/sql_db.py @@ -297,9 +297,9 @@ def select_one_or_none(self, table_or_stmt, where=None): def __conn(self): if self._conn is None: - self._conn = self.meta._engine.connect() - self._conn.execute("PRAGMA foreign_keys = ON;") + self._conn = self.meta._engine.connect().execution_options(autobegin=False) self._txn = self._conn.begin() + self._conn.execute(sqlalchemy.text("PRAGMA foreign_keys = ON;")) return self._conn def __execute_table_or_stmt(self, method, table_or_stmt, where): @@ -374,7 +374,7 @@ def fixup_post_insert(self, db, values, inserted_primary_key): """ # we do not handle multi column inserted_primary_keys if self.has_primary_id and inserted_primary_key is not None: - values[self.primary_id] = inserted_primary_key[self.primary_id] + values[self.primary_id] = inserted_primary_key._mapping[self.primary_id] return values def fixup_pre_insert(self, session, values): diff --git a/pyproject.toml b/pyproject.toml index a4901525..0ae0f3f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ dependencies = [ "setuptools>=66", "six>=1.9", "Sphinx>=1.3.5", - "SQLAlchemy>=1.4,<2", + "SQLAlchemy", "toml>=0.10", "tornado", "urllib3",