【问题标题】:Compiler state error when inserting data to CrateDb将数据插入 CrateDb 时出现编译器状态错误
【发布时间】:2021-10-17 17:26:42
【问题描述】:

我正在尝试连接到 crateDB 并插入数据。虽然数据库迁移工作完美 - 它在尝试插入数据时显示以下错误

TypeError: _get_crud_params() missing 1 required positional argument: 'compile_state'

以下是我的代码:

engine = create_engine('crate://localhost:4200', echo=False)

class Devices(Base):
    __tablename__ = 'registereddevices'
    id = Column('id',Integer, primary_key=True)
    bunkId = Column('bunkId', String)
    deviceType = Column('deviceType', String)
    deviceName = Column('deviceName', String)

Base.metadata.create_all(bind=engine)
Session = sessionmaker(bind=engine)
session = Session()

try:
    device = Devices()
    device.id = 1
    device.bunkId = "sads"
    device.deviceType = "fdsfd"
    device.deviceName = "gdf"

    session.add(device)
    session.commit()
except exc.SQLAlchemyError as e:
    print(type(e))

【问题讨论】:

    标签: python-3.x sqlalchemy cratedb


    【解决方案1】:

    您使用的是 SQLAlchemy 1.4 吗?根据Dialects 页面的脚注,crate-python 目前仅与 SQLAlchemy 1.3 兼容。

    如果您需要坚持使用 1.4,您也可以尝试使用常规 PostgreSQL 驱动程序,因为 CrateDB 的 SQL 方言与 PostgreSQL 广泛兼容。

    【讨论】:

    • 好收获!我错过了。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-02
    • 2021-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多