我奮力運行SELECT *在SQL鍊金術查詢,我的表對象看起來像這樣,選擇*在SQLAlchemy的
from sqlalchemy import Column, Date, DateTime, Float, Numeric, Index, Integer, MetaData, SmallInteger, String, UnicodeText, Table, Time, text
from sqlalchemy.types import _Binary
metadata = MetaData()
absence = Table(
'absence', metadata,
Column('id', Integer, primary_key=True),
Column('workbase', String(255), index=True),
Column('name', String(255), nullable=False, index=True),
Column('submit_date', DateTime, index=True),
Column('created_1', DateTime, index=True),
Column('manager_1', String(255), index=True),
Column('first_day_1', Date, index=True),
Column('last_day_1', Date, index=True),
Column('sp_absence_id', Integer, index=True),
Column('created_2', DateTime, index=True),
Column('manager_2', String(255), index=True),
Column('first_day_2', Date, index=True),
Column('last_day_2', Date, index=True),
Column('sp_selfcert_id', Integer, index=True),
Column('sp_selfcert_file', String(255), index=True),
Column('interview_date', Date, index=True),
Column('created_3', DateTime, index=True),
Column('manager_3', String(255), index=True),
Column('first_day_3', Date, index=True),
Column('sp_return_id', Integer, index=True),
Column('sp_return_file', String(255)),
Column('rostered_days', Float(24), index=True),
Column('reason', String(255), nullable=False, index=True),
Column('rtw_trigger', Integer, index=True)
)
我曾嘗試選擇所有
absence = tables.absence
#Attempt 1
absence.all()
returns AttributeError: 'Table' object has no attribute 'all'
#Attempt 2
absence.query.all()
returns AttributeError: 'Table' object has no attribute 'query'
#Attempt 3
sel = select([absence.c.*]).select_from(absence)
absences = FlaskApp.db_connect().execute(sel).fetchall()
returns nothing, but kills my local server.
無的無數種方法上面的工作,我做錯了我以前在其他語言中使用ORM,他們一直很容易,