Skip to content

Commit f807f1e

Browse files
committed
added support for SQLAlchemy 2.0
1 parent 464f237 commit f807f1e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
"Topic :: Software Development :: Libraries :: Python Modules"
1111
],
1212
description="CS50 library for Python",
13-
install_requires=["Flask>=1.0", "SQLAlchemy==1.4.46", "sqlparse", "termcolor", "wheel"],
13+
install_requires=["Flask>=1.0", "SQLAlchemy<3", "sqlparse", "termcolor", "wheel"],
1414
keywords="cs50",
1515
license="GPLv3",
1616
long_description_content_type="text/markdown",
1717
name="cs50",
1818
package_dir={"": "src"},
1919
packages=["cs50"],
2020
url="https://github.com/cs50/python-cs50",
21-
version="9.2.5"
21+
version="9.2.6"
2222
)

src/cs50/sql.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def __init__(self, url, **kwargs):
5353
import sqlalchemy
5454
import sqlalchemy.orm
5555
import threading
56-
56+
5757
# Temporary fix for missing sqlite3 module on the buildpack stack
5858
try:
5959
import sqlite3
@@ -100,7 +100,7 @@ def connect(dbapi_connection, connection_record):
100100
self._logger.disabled = True
101101
try:
102102
connection = self._engine.connect()
103-
connection.execute("SELECT 1")
103+
connection.execute(sqlalchemy.text("SELECT 1"))
104104
connection.close()
105105
except sqlalchemy.exc.OperationalError as e:
106106
e = RuntimeError(_parse_exception(e))
@@ -344,7 +344,7 @@ def teardown_appcontext(exception):
344344
if command == "SELECT":
345345

346346
# Coerce types
347-
rows = [dict(row) for row in result.fetchall()]
347+
rows = [dict(row) for row in result.mappings().all()]
348348
for row in rows:
349349
for column in row:
350350

0 commit comments

Comments
 (0)