繁体   English   中英

向 CrateDb 插入数据时出现编译器 state 错误

[英]Compiler state error when inserting data to CrateDb

我正在尝试连接到 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))

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM