Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update handling of execution for sqlalchemy 2+ #71

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
update handling of execution for sqlalchemy 2+
Zachary Charlop-Powers authored and Zachary Charlop-Powers committed Dec 10, 2023
commit 2498ec327116d858473cc4986c5766844c7cfaf0
13 changes: 11 additions & 2 deletions pugsql/compiler.py
Original file line number Diff line number Diff line change
@@ -134,12 +134,21 @@ def transaction(self):

def _execute(self, clause, *multiparams, **params):
if getattr(self._locals, 'session', None):
return self._locals.session.execute(clause, multiparams or params)
with self._locals.session.connect() as conn:
result = conn.execute(clause)
print(result)
return result
# return self._locals.session.execute(clause, multiparams or params)

if not self.engine:
raise NoConnectionError()

return self.engine.execute(clause, *multiparams, **params)
print("in local")
#return self.engine.execute(clause, *multiparams, **params)
with self.engine.connect() as conn:
result = conn.execute(clause)
print(result)
return result

@property
def _dialect(self):
13 changes: 8 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -17,15 +17,18 @@ readme = "pypi-readme.md"

[tool.poetry.dependencies]
python = ">=3.7"
sqlalchemy = "^1.3"
sqlalchemy = "^2.0"

[tool.poetry.dev-dependencies]
pdoc3 = "^0.6.2"
pg8000 = "^1.13"
packaging = "^20.4"
pytest = "^7.1.0"
flake8 = "^4.0.1"
pg8000 = "^1.30"
packaging = "^23.2"
pytest = "^7.2.0"
flake8 = "^6.1.1"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

[project]
version = "0.1.0"