注册

SQLAlchemy使用时列名大小写问题,

下头 2025/02/13 361 11

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
SQLAlchemy 1.4.46
sqlalchemy-dm 1.4.39

使用如下语句时
table = Table(table_name, metadata, autoload_with=engine, schema=schema)
print(f"表名: {table.name}")
for column in table.columns:
print(f"列名: {column.name}, 类型: {column.type}")

engine.connect().execute(select(
[table.c.hhr_task_id]).where(table.c.TENANT_ID == 3)).fetchone()

会报
KeyError: 'hhr_task_id'

The above exception was the direct cause of the following exception:

只有把hhr_task_id 改为大写才可以使用

回答 0
暂无回答
扫一扫
联系客服