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

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2025-01-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

Passing a string instead of a SQLAlchemy type object to Column.

generic

中文

向 Column 传递字符串而不是 SQLAlchemy 类型对象。

Workarounds

  1. 95% success Use proper SQLAlchemy type.
    from sqlalchemy import Column, Integer, String
    Column('id', Integer, primary_key=True)
  2. 90% success Check import statements.
    from sqlalchemy.types import Integer, String

Dead Ends

Common approaches that don't work:

  1. Using string like 'Integer' as type. 90% fail

    Must import and use Integer class.

  2. Using type as positional argument incorrectly. 70% fail

    Column expects type as first positional arg; wrong order causes error.