File tree Expand file tree Collapse file tree 4 files changed +16
-10
lines changed
django_prometheus/db/backends Expand file tree Collapse file tree 4 files changed +16
-10
lines changed Original file line number Diff line number Diff line change 77* Support new cache backend names in newer Django versions, Thanks [ @tneuct ] ( https://github.com/korfuri/django-prometheus/pull/329 )
88* Make export of migrations False by default, Thanks [ @kaypee90 ] ( https://github.com/korfuri/django-prometheus/pull/313 )
99* Add support for Django 4.1, Python 3.11
10+ * Add support for Django 4.2 and Psycopg 3
1011
1112## v2.2.0 - December 19, 2021
1213
Original file line number Diff line number Diff line change 1- import psycopg2 . extensions
1+ from django import VERSION
22from django .contrib .gis .db .backends .postgis import base
33
44from django_prometheus .db .common import DatabaseWrapperMixin , ExportingCursorWrapper
55
6+ if VERSION < (4 , 2 ):
7+ from psycopg2 .extensions import cursor as cursor_cls
8+ else :
9+ from django .db .backends .postgresql .base import Cursor as cursor_cls
10+
611
712class DatabaseWrapper (DatabaseWrapperMixin , base .DatabaseWrapper ):
813 def get_connection_params (self ):
914 conn_params = super ().get_connection_params ()
10- conn_params ["cursor_factory" ] = ExportingCursorWrapper (psycopg2 . extensions . cursor , "postgis" , self .vendor )
15+ conn_params ["cursor_factory" ] = ExportingCursorWrapper (cursor_cls , "postgis" , self .vendor )
1116 return conn_params
1217
1318 def create_cursor (self , name = None ):
Original file line number Diff line number Diff line change 1- import psycopg2 . extensions
2- from django .db .backends .postgresql import base
1+ from django import VERSION
2+ from django .contrib . gis . db .backends .postgis import base
33
44from django_prometheus .db .common import DatabaseWrapperMixin , ExportingCursorWrapper
55
6-
7- class DatabaseFeatures (base .DatabaseFeatures ):
8- """Our database has the exact same features as the base one."""
9-
10- pass
6+ if VERSION < (4 , 2 ):
7+ from psycopg2 .extensions import cursor as cursor_cls
8+ else :
9+ from django .db .backends .postgresql .base import Cursor as cursor_cls
1110
1211
1312class DatabaseWrapper (DatabaseWrapperMixin , base .DatabaseWrapper ):
1413 def get_connection_params (self ):
1514 conn_params = super ().get_connection_params ()
16- conn_params ["cursor_factory" ] = ExportingCursorWrapper (psycopg2 . extensions . cursor , self .alias , self .vendor )
15+ conn_params ["cursor_factory" ] = ExportingCursorWrapper (cursor_cls , self .alias , self .vendor )
1716 return conn_params
1817
1918 def create_cursor (self , name = None ):
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ def get_version():
5959 "Framework :: Django :: 3.2" ,
6060 "Framework :: Django :: 4.0" ,
6161 "Framework :: Django :: 4.1" ,
62+ "Framework :: Django :: 4.2" ,
6263 "Topic :: System :: Monitoring" ,
6364 "License :: OSI Approved :: Apache Software License" ,
6465 ],
You can’t perform that action at this time.
0 commit comments