简体   繁体   中英

Compiler state error when inserting data to CrateDb

I am trying to connect to the crateDB and insert data. Although the DB migrations work perfectly - it shows the following error when am trying to insert data

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

Following is my code:

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))

are you using SQLAlchemy 1.4? As per the footnote on the Dialects page, crate-python is currently only compatible with SQLAlchemy 1.3.

If you need to stick to 1.4, you might also try using a regular PostgreSQL driver, as CrateDB's SQL dialect is widely compatible with PostgreSQL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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