Comments (7)
I was able to solve this for me with the following patch
def sa_patch():
"""
sqlalchemy patch to make aiopg.sa work correctly
"""
import sqlalchemy
from sqlalchemy.dialects.postgresql import base, psycopg2
class PGDialect_psycopg2(psycopg2.PGDialect_psycopg2):
case_sensitive = True
description_encoding = None
setattr(sqlalchemy.dialects.postgresql.psycopg2, 'PGCompiler_psycopg2', base.PGCompiler)
setattr(sqlalchemy.dialects.postgresql.psycopg2, 'PGDialect_psycopg2', PGDialect_psycopg2)
And this function must be called every time before importing
sa_patch()
import aiopg.sa
from aiopg.
Hello,
In the long run, it is better to upgrade(from my point of view) to sqlalchemy native async support, which was introduced in sqlalchemy v1.4 (initially, asyncpg was the only one supported) and continued in sqlachemy v2. Currently, sqlalchemy v2 has built-in async support of asyncpg and psycopg v3.
Aiopg was vital before sqlachemy began to support async, but now it doesn't make much sense for further support.
I am happy to merge any compatibility patches with sqlalchemy v2, but there are no activities from my side to support it.
from aiopg.
Resolved by #901
from aiopg.
Still reproduced -> Ubuntu 22.04 -> sqlalchemy '2.0.3', Python 3.10.6, aiopg 1.4.0
from aiopg.
Seeing the same. Problem comes from trying to import this:
try:
from sqlalchemy.dialects.postgresql.psycopg2 import (
PGCompiler_psycopg2,
PGDialect_psycopg2,
)
except ImportError: # pragma: no cover
raise ImportError("aiopg.sa requires sqlalchemy")
But the PGCompiler_psycopg2 object doesn't exist anymore in this script https://github.com/sqlalchemy/sqlalchemy/blob/main/lib/sqlalchemy/dialects/postgresql/psycopg2.py
from aiopg.
Are there any news for this issue? I tried alphavector's solution and it worked but official support for sqlalchemy v2 would be much appreciated. Are there any plans for this ?
from aiopg.
@asvetlov
#798 (comment) seems to have the same opinion on that.
from aiopg.
Related Issues (20)
- aiopg 1.1.0+ is incompatible with SQLAlchemy 1.4 HOT 23
- Cursor.execute() freezes + Pool.wait_closed() blocks after Pool.close() HOT 2
- aiopg1.2 incompatible with peewee-async HOT 1
- executing a query on a closed SAConnection throws a non-indicative exception HOT 2
- Update "table" with inverse (logic) doesn't work
- FileNotFoundError when connecting to postgres if fd is closed and then reopened HOT 6
- Replace dependency psycopg2-binary with psycopg2 HOT 1
- unable to perform operation on <UVPoll closed=True 0x7fe55db27270>; the handler is closed
- Incompatibility with SQLAlchemy 1.4
- SAConnection twophase methods are broken
- Roadmap after psycopg3 release HOT 2
- Incompatible with SQLAlchemy 1.4.38 and higher HOT 7
- AttributeError: 'Connection' object has no attribute 'send' HOT 1
- 1.4.0: documentation cannot be build using latest sphinx
- Sometimes got error
- Allow just-in-time compution of credentials for new connections in a pool
- Let's put `aiopg` under the `aio-libs` org on PyPI HOT 3
- NotImplementedError 😢
- aiopg times out while attempting to connect if falling back to an IPv4 address HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiopg.