python
type_error
ai_generated
true
sqlalchemy.exc.ArgumentError:Column() 的 'type' 参数应为 TypeEngine,而不是 <class 'str'>
sqlalchemy.exc.ArgumentError: The 'type' argument of Column() should be a TypeEngine, not a <class 'str'>
ID: python/sqlalchemy-type-error-mapping
80%修复率
85%置信度
0证据数
2025-01-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
向 Column 传递字符串而不是 SQLAlchemy 类型对象。
English
Passing a string instead of a SQLAlchemy type object to Column.
解决方案
-
95% 成功率 Use proper SQLAlchemy type.
from sqlalchemy import Column, Integer, String Column('id', Integer, primary_key=True) -
90% 成功率 Check import statements.
from sqlalchemy.types import Integer, String
无效尝试
常见但无效的做法:
-
Using string like 'Integer' as type.
90% 失败
Must import and use Integer class.
-
Using type as positional argument incorrectly.
70% 失败
Column expects type as first positional arg; wrong order causes error.