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

Support SQLAlchemy 2.0 #174

Merged
merged 7 commits into from
Oct 24, 2023
Merged
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
Prev Previous commit
Next Next commit
convert string to sqlalchemy text
rongxin-liu committed Sep 13, 2023
commit ca09441d54ab52805baa38d50fe47c33bf4dcc65
4 changes: 2 additions & 2 deletions src/cs50/sql.py
Original file line number Diff line number Diff line change
@@ -370,7 +370,7 @@ def teardown_appcontext(exception):
# "(psycopg2.errors.ObjectNotInPrerequisiteState) lastval is not yet defined in this session",
# a la https://stackoverflow.com/a/24186770/5156190;
# cf. https://www.psycopg.org/docs/errors.html re 55000
result = connection.execute("""
result = connection.execute(sqlalchemy.text("""
CREATE OR REPLACE FUNCTION _LASTVAL()
RETURNS integer LANGUAGE plpgsql
AS $$
@@ -382,7 +382,7 @@ def teardown_appcontext(exception):
END;
END $$;
SELECT _LASTVAL();
""")
"""))
ret = result.first()[0]

# If not PostgreSQL