python
type_error
ai_generated
true
sqlalchemy.exc.ArgumentError: The 'type' argument of Column() should be a TypeEngine, not a <class 'str'>
ID: python/sqlalchemy-type-error-mapping
80%Fix Rate
85%Confidence
0Evidence
2025-01-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
Passing a string instead of a SQLAlchemy type object to Column.
generic中文
向 Column 传递字符串而不是 SQLAlchemy 类型对象。
Workarounds
-
95% success Use proper SQLAlchemy type.
from sqlalchemy import Column, Integer, String Column('id', Integer, primary_key=True) -
90% success Check import statements.
from sqlalchemy.types import Integer, String
Dead Ends
Common approaches that don't work:
-
Using string like 'Integer' as type.
90% fail
Must import and use Integer class.
-
Using type as positional argument incorrectly.
70% fail
Column expects type as first positional arg; wrong order causes error.