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 7
7
* Support new cache backend names in newer Django versions, Thanks [ @tneuct ] ( https://github.com/korfuri/django-prometheus/pull/329 )
8
8
* Make export of migrations False by default, Thanks [ @kaypee90 ] ( https://github.com/korfuri/django-prometheus/pull/313 )
9
9
* Add support for Django 4.1, Python 3.11
10
+ * Add support for Django 4.2 and Psycopg 3
10
11
11
12
## v2.2.0 - December 19, 2021
12
13
Original file line number Diff line number Diff line change 1
- import psycopg2 . extensions
1
+ from django import VERSION
2
2
from django .contrib .gis .db .backends .postgis import base
3
3
4
4
from django_prometheus .db .common import DatabaseWrapperMixin , ExportingCursorWrapper
5
5
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
+
6
11
7
12
class DatabaseWrapper (DatabaseWrapperMixin , base .DatabaseWrapper ):
8
13
def get_connection_params (self ):
9
14
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 )
11
16
return conn_params
12
17
13
18
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
3
3
4
4
from django_prometheus .db .common import DatabaseWrapperMixin , ExportingCursorWrapper
5
5
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
11
10
12
11
13
12
class DatabaseWrapper (DatabaseWrapperMixin , base .DatabaseWrapper ):
14
13
def get_connection_params (self ):
15
14
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 )
17
16
return conn_params
18
17
19
18
def create_cursor (self , name = None ):
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ def get_version():
59
59
"Framework :: Django :: 3.2" ,
60
60
"Framework :: Django :: 4.0" ,
61
61
"Framework :: Django :: 4.1" ,
62
+ "Framework :: Django :: 4.2" ,
62
63
"Topic :: System :: Monitoring" ,
63
64
"License :: OSI Approved :: Apache Software License" ,
64
65
],
You can’t perform that action at this time.
0 commit comments