Skip to content

Commit

Permalink
Merge pull request #49 from aaronsmith1234/master
Browse files Browse the repository at this point in the history
fixing breakage from SqlAlchemy 1.4
  • Loading branch information
MacHu-GWU authored Apr 5, 2021
2 parents 53f37b9 + 73df027 commit 964ce41
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,4 @@ $RECYCLE.BIN/

# Windows shortcuts
*.lnk
.vscode/settings.json
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
attrs
sqlalchemy
SQLAlchemy>=1.4.0
pathlib_mate
requests
8 changes: 4 additions & 4 deletions uszipcode/pkg/sqlalchemy_mate/pt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

from sqlalchemy import select, Table
from sqlalchemy.orm import sessionmaker, Query
from sqlalchemy.ext.declarative.api import DeclarativeMeta
from sqlalchemy.orm import DeclarativeMeta
from sqlalchemy.sql.selectable import Select
from sqlalchemy.engine.result import ResultProxy
from sqlalchemy.engine.result import Result

try:
from .utils import execute_query_return_result_proxy
Expand All @@ -34,7 +34,7 @@ def from_sql(sql, engine, limit=None):
.. note::
注意, from_db_cursor是从原生的数据库游标通过调用fetchall()方法来获取数据。
而sqlalchemy返回的是ResultProxy类。所以我们需要从中获取游标
而sqlalchemy返回的是Result类。所以我们需要从中获取游标
至于为什么不能直接使用 from_db_cursor(engine.execute(sql).cursor) 的语法
我也不知道为什么.
"""
Expand Down Expand Up @@ -144,7 +144,7 @@ def from_everything(everything, engine, limit=None):
if isinstance(everything, Select):
return from_sql(everything, engine, limit=limit)

if isinstance(everything, ResultProxy):
if isinstance(everything, Result):
return from_resultproxy(everything)

if isinstance(everything, list):
Expand Down

0 comments on commit 964ce41

Please sign in to comment.