asyncpgsa
asyncpgsa copied to clipboard
compile_query fails with sqlalchemy 1.4
This works fine with asyncpgsa version 0.27.1 and sqlalchemy: 1.3.23, but fails when I upgrade to sqlalchemy 1.4.4.
import asyncpgsa
import sqlalchemy as sa
Thing = sa.Table("thing", sa.MetaData(), sa.Column("name", sa.Text))
query = Thing.insert().values(name="name").returning(Thing)
asyncpgsa.compile_query(query)
This prevents me from running any code that uses an INSERT statement.
The error seems to be here:
https://github.com/CanopyTax/asyncpgsa/blob/master/asyncpgsa/connection.py#L36
if isinstance(query.parameters, list):
because sqlalchemy.sql.dml.Insert
no longer has a parameters
attribute.
For now I'm dealing with this by pinning to an earlier sqlalchemy version. It's not clear to me what the fix should be, because the sqlalchemy internals seem to have changed considerably between versions.
For some new projects maybe a good choice to use async support of sqlalchemy
asyncio extension in sqlalchemy
I am thinking about this transition. I think it would be good to have some benchmarks for this..
I am actually thinking of deprecating this library now that sqlalchemy supports asyncpg directly. I already migrated an application too it, and might provide a migration guide.
A migration guide would be helpful - I've built a number of projects on top of asyncpg over the years. Thank you for all your work in creating it, maintaining it, and being so responsive to my questions. (You helped me with a JSON encoding issue at PyCon a few years ago, if I recall correctly.)
Just for the record. Native async support SQLAlchemy has some problems. And the most of them probably will never be fixed. The most notable is the lack of auto-commit mode, and wrapping each select into async with db.begin():
is really annoying. Also it has issues with pgbouncer.
+1 for the migration guide.