Python 使用SQLAlchemy core:AttributeError:“unicode”对象没有属性“shares\u沿袭”
我试图使用SQLAlchemy core从表中选择数据Python 使用SQLAlchemy core:AttributeError:“unicode”对象没有属性“shares\u沿袭”,python,sqlalchemy,Python,Sqlalchemy,我试图使用SQLAlchemy core从表中选择数据 import sqlalchemy as sa ... with database_engine.connect() as conn: s = map(dict, conn.execute(sa.select([destination.c]))) print s 但我得到了以下错误: /wowcomputers/.virtualenvs/project/lib/python2.7/site-packages/sqlalchemy/
import sqlalchemy as sa
...
with database_engine.connect() as conn:
s = map(dict, conn.execute(sa.select([destination.c])))
print s
但我得到了以下错误:
/wowcomputers/.virtualenvs/project/lib/python2.7/site-packages/sqlalchemy/sql/selectable.pyc in __init__(self, columns, whereclause, from_obj, distinct, having, correlate, prefixes, suffixes, **kwargs)
2450 self._raw_columns = []
2451 for c in columns:
-> 2452 c = _interpret_as_column_or_from(c)
2453 if isinstance(c, ScalarSelect):
2454 c = c.self_group(against=operators.comma_op)
/wowcomputers/.virtualenvs/project/lib/python2.7/site-packages/sqlalchemy/sql/elements.pyc in _interpret_as_column_or_from(element)
3852 # be forgiving as this is an extremely common
3853 # and known expression
-> 3854 if element == "*":
3855 guess_is_literal = True
3856 elif isinstance(element, (numbers.Number)):
<string> in <lambda>(self, other)
/wowcomputers/.virtualenvs/project/lib/python2.7/site-packages/sqlalchemy/sql/base.pyc in __eq__(self, elements, other)
569 for c in getattr(other, "_all_columns", other):
570 for local in self._all_columns:
--> 571 if c.shares_lineage(local):
572 l.append(c == local)
573 return elements.and_(*l)
AttributeError: 'unicode' object has no attribute 'shares_lineage'
我做错了什么?使用sqlachemy.core执行select时,需要传递select可选择项列表
sa.select([destination.c.column1, destination.c.column2])
在将所有列传递到select语句时,忘记删除换行列表是一种常见的拼写错误,因此请更改
sa.select([destination.c])
对此
sa.select(destination.c)
使用sqlachemy.core执行select时,需要传递select可选择项列表
sa.select([destination.c.column1, destination.c.column2])
在将所有列传递到select语句时,忘记删除换行列表是一种常见的拼写错误,因此请更改
sa.select([destination.c])
对此
sa.select(destination.c)