Skip to content

Commit 28ce76f

Browse files
committed
Add support to psycopg 3
1 parent 11e9ec7 commit 28ce76f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

dj_db_conn_pool/backends/postgresql/mixins.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
# coding: utf-8
2+
import importlib
3+
4+
try:
5+
importlib.import_module("psycopg")
6+
from sqlalchemy.dialects.postgresql.psycopg import PGDialect_psycopg as PGDialect
7+
except ModuleNotFoundError:
8+
from sqlalchemy.dialects.postgresql.psycopg2 import PGDialect_psycopg2 as PGDialect
29

3-
from sqlalchemy.dialects.postgresql.psycopg2 import PGDialect_psycopg2
410

511
from dj_db_conn_pool.core.mixins import PersistentDatabaseWrapperMixin
612

713

814
class PGDatabaseWrapperMixin(PersistentDatabaseWrapperMixin):
9-
class SQLAlchemyDialect(PGDialect_psycopg2):
15+
class SQLAlchemyDialect(PGDialect):
1016
pass
1117

1218
def get_new_connection(self, conn_params):

pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ mysql = ["mysqlclient>=1.3.0"]
4444
odbc = ["pyodbc>=4.0.34"]
4545
oracle = ["cx-Oracle>=6.4.1"]
4646
postgresql = ["psycopg2>=2.8.6"]
47+
psycopg2 = ["psycopg2>=2.8.6"]
48+
psycopg3 = ["psycopg>=3"]
4749

4850
[build-system]
4951
requires = ["setuptools"]

0 commit comments

Comments
 (0)