koxudaxi / py-data-api

A user-friendly client for AWS Aurora Serverless's Data API
https://koxudaxi.github.io/py-data-api
MIT License
40 stars 9 forks source link

BadRequestException: An error occurred (BadRequestException) when calling the ExecuteStatement operation: ERROR: syntax error at or near "like" Position: 16 #68

Closed franz101 closed 4 years ago

franz101 commented 4 years ago

Creating a table through SQLAlchemy with the following code: ` meta = MetaData()

Table( "pets", meta, Column("id",Integer, primary_key=True, autoincrement=True), Column("name",String(255), default=None) )

meta.create_all(engine) `

I get the give error....

Also with: Pets.__table__.create(engine)

Is not implemented yet?

franz101 commented 4 years ago

My bad connected with mysql to Postgres...

koxudaxi commented 4 years ago

@franz101 No problem! you feel free to contact me when you have any questions :nerd_face: thank you for closing the issue.

franz101 commented 4 years ago

Thanks for your kind reply @koxudaxi This time I get a casting error for Postgres when inserting a file with JSONB I attached a possible solution at the bottom.

from sqlalchemy.dialects.postgresql.json import JSONB from sqlalchemy.dialects.postgresql import insert as pg_insert

player=PJsonObj(PK=player['id'], SK=player['SK'], data=player, updated=str(datetime.datetime.now()))

table = Table( "test_table", MetaData(), Column('PK',String, nullable=False), Column('SK',String, nullable=False), Column("data",JSONB), Column('updated',Date, nullable=True), PrimaryKeyConstraint("PK","SK") )

engine.execute(pg_insert(table,player.as_dict())

May be related to this: https://github.com/chanzuckerberg/aurora-data-api/issues/3

koxudaxi commented 4 years ago

@franz101 Thank you for posting the problem and workaround. I have created a new issue for this problem. I will resolve it.