database-wrapper-pgsql 0.2.17__tar.gz → 0.2.24__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/PKG-INFO +2 -2
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql/__init__.py +25 -21
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql/connector.py +33 -23
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql/db_wrapper_pgsql.py +3 -5
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql/db_wrapper_pgsql_async.py +2 -2
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql/db_wrapper_pgsql_mixin.py +2 -2
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql.egg-info/PKG-INFO +2 -2
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql.egg-info/requires.txt +1 -1
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/pyproject.toml +5 -7
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/README.md +0 -0
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql/pg_introspector.py +0 -0
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql/py.typed +0 -0
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql/type_mapping.py +0 -0
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql.egg-info/SOURCES.txt +0 -0
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql.egg-info/dependency_links.txt +0 -0
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql.egg-info/top_level.txt +0 -0
- {database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: database_wrapper_pgsql
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.24
|
|
4
4
|
Summary: database_wrapper for PostgreSQL database
|
|
5
5
|
Author-email: Gints Murans <gm@gm.lv>
|
|
6
6
|
License: GNU General Public License v3.0 (GPL-3.0)
|
|
@@ -32,7 +32,7 @@ Classifier: Topic :: Software Development
|
|
|
32
32
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
33
33
|
Requires-Python: >=3.8
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
|
-
Requires-Dist: database_wrapper==0.2.
|
|
35
|
+
Requires-Dist: database_wrapper==0.2.24
|
|
36
36
|
Requires-Dist: psycopg[binary]>=3.2.0
|
|
37
37
|
Requires-Dist: psycopg[pool]>=3.2.0
|
|
38
38
|
|
{database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql/__init__.py
RENAMED
|
@@ -10,20 +10,21 @@ import logging
|
|
|
10
10
|
|
|
11
11
|
from .connector import (
|
|
12
12
|
# Basics
|
|
13
|
-
|
|
14
|
-
# Connection and Cursor types
|
|
13
|
+
PgConnection,
|
|
15
14
|
PgConnectionType,
|
|
16
15
|
PgConnectionTypeAsync,
|
|
16
|
+
PgCursor,
|
|
17
17
|
PgCursorType,
|
|
18
18
|
PgCursorTypeAsync,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
PgDictRow,
|
|
20
|
+
Pgsql,
|
|
21
|
+
PgsqlAsync,
|
|
22
|
+
PgsqlConfig,
|
|
23
|
+
PgsqlWithPooling,
|
|
24
|
+
PgsqlWithPoolingAsync,
|
|
24
25
|
)
|
|
25
|
-
from .db_wrapper_pgsql import
|
|
26
|
-
from .db_wrapper_pgsql_async import
|
|
26
|
+
from .db_wrapper_pgsql import DBWrapperPgsql
|
|
27
|
+
from .db_wrapper_pgsql_async import DBWrapperPgsqlAsync
|
|
27
28
|
from .pg_introspector import PostgresIntrospector
|
|
28
29
|
|
|
29
30
|
# Set the logger to a quiet default, can be enabled if needed
|
|
@@ -34,19 +35,22 @@ if logger.level == logging.NOTSET:
|
|
|
34
35
|
|
|
35
36
|
__all__ = [
|
|
36
37
|
# Wrappers
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
DBWrapperPgsql,
|
|
39
|
+
DBWrapperPgsqlAsync,
|
|
39
40
|
# Connectors
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
Pgsql,
|
|
42
|
+
PgsqlAsync,
|
|
43
|
+
PgsqlWithPooling,
|
|
44
|
+
PgsqlWithPoolingAsync,
|
|
44
45
|
# Connection and Cursor types
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
PgConnection,
|
|
47
|
+
PgConnectionType,
|
|
48
|
+
PgConnectionTypeAsync,
|
|
49
|
+
PgCursor,
|
|
50
|
+
PgCursorType,
|
|
51
|
+
PgCursorTypeAsync,
|
|
52
|
+
PgDictRow,
|
|
49
53
|
# Helpers
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
PgsqlConfig,
|
|
55
|
+
PostgresIntrospector,
|
|
52
56
|
]
|
{database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql/connector.py
RENAMED
|
@@ -21,7 +21,7 @@ PgConnectionTypeAsync = PgConnectionAsync[PgDictRow]
|
|
|
21
21
|
PgCursorTypeAsync = PgCursorAsync[PgDictRow]
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
class
|
|
24
|
+
class PgsqlConfig(TypedDict):
|
|
25
25
|
hostname: str
|
|
26
26
|
port: NotRequired[int]
|
|
27
27
|
username: str
|
|
@@ -35,7 +35,7 @@ class PgConfig(TypedDict):
|
|
|
35
35
|
pool_kwargs: NotRequired[dict[str, Any]]
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
class
|
|
38
|
+
class Pgsql(DatabaseBackend):
|
|
39
39
|
"""
|
|
40
40
|
PostgreSQL database implementation.
|
|
41
41
|
|
|
@@ -45,7 +45,7 @@ class PgSQL(DatabaseBackend):
|
|
|
45
45
|
Close is called automatically when class is destroyed.
|
|
46
46
|
|
|
47
47
|
:param config: Configuration for PostgreSQL
|
|
48
|
-
:type config:
|
|
48
|
+
:type config: PgsqlConfig
|
|
49
49
|
|
|
50
50
|
Defaults:
|
|
51
51
|
port = 5432
|
|
@@ -53,7 +53,7 @@ class PgSQL(DatabaseBackend):
|
|
|
53
53
|
|
|
54
54
|
"""
|
|
55
55
|
|
|
56
|
-
config:
|
|
56
|
+
config: PgsqlConfig
|
|
57
57
|
|
|
58
58
|
connection: PgConnectionType
|
|
59
59
|
cursor: PgCursorType
|
|
@@ -152,7 +152,7 @@ class PgSQL(DatabaseBackend):
|
|
|
152
152
|
self.connection.rollback()
|
|
153
153
|
|
|
154
154
|
|
|
155
|
-
class
|
|
155
|
+
class PgsqlAsync(DatabaseBackend):
|
|
156
156
|
"""
|
|
157
157
|
PostgreSQL database async implementation.
|
|
158
158
|
|
|
@@ -163,7 +163,7 @@ class PgSQLAsync(DatabaseBackend):
|
|
|
163
163
|
! You need to call it manually in async environment.
|
|
164
164
|
|
|
165
165
|
:param config: Configuration for PostgreSQL
|
|
166
|
-
:type config:
|
|
166
|
+
:type config: PgsqlConfig
|
|
167
167
|
|
|
168
168
|
Defaults:
|
|
169
169
|
port = 5432
|
|
@@ -171,7 +171,7 @@ class PgSQLAsync(DatabaseBackend):
|
|
|
171
171
|
|
|
172
172
|
"""
|
|
173
173
|
|
|
174
|
-
config:
|
|
174
|
+
config: PgsqlConfig
|
|
175
175
|
|
|
176
176
|
connection: PgConnectionTypeAsync
|
|
177
177
|
cursor: PgCursorTypeAsync
|
|
@@ -220,13 +220,23 @@ class PgSQLAsync(DatabaseBackend):
|
|
|
220
220
|
|
|
221
221
|
async def close(self) -> Any:
|
|
222
222
|
"""Close connections"""
|
|
223
|
-
|
|
224
|
-
self
|
|
225
|
-
|
|
223
|
+
try:
|
|
224
|
+
if hasattr(self, "cursor") and self.cursor:
|
|
225
|
+
self.logger.debug("Closing cursor")
|
|
226
|
+
await self.cursor.close()
|
|
227
|
+
except Exception as e:
|
|
228
|
+
self.logger.debug(f"Error while closing cursor: {e}")
|
|
229
|
+
finally:
|
|
230
|
+
self.cursor = None
|
|
226
231
|
|
|
227
|
-
|
|
228
|
-
self
|
|
229
|
-
|
|
232
|
+
try:
|
|
233
|
+
if hasattr(self, "connection") and self.connection:
|
|
234
|
+
self.logger.debug("Closing connection")
|
|
235
|
+
await self.connection.close()
|
|
236
|
+
except Exception as e:
|
|
237
|
+
self.logger.debug(f"Error while closing connection: {e}")
|
|
238
|
+
finally:
|
|
239
|
+
self.connection = None
|
|
230
240
|
|
|
231
241
|
async def ping(self) -> bool:
|
|
232
242
|
try:
|
|
@@ -280,7 +290,7 @@ class PgSQLAsync(DatabaseBackend):
|
|
|
280
290
|
await self.connection.rollback()
|
|
281
291
|
|
|
282
292
|
|
|
283
|
-
class
|
|
293
|
+
class PgsqlWithPooling(DatabaseBackend):
|
|
284
294
|
"""
|
|
285
295
|
PostgreSQL database implementation with connection pooling.
|
|
286
296
|
|
|
@@ -292,13 +302,13 @@ class PgSQLWithPooling(DatabaseBackend):
|
|
|
292
302
|
Or use context manager to get connection and return it back automatically,
|
|
293
303
|
for example:
|
|
294
304
|
|
|
295
|
-
pool =
|
|
305
|
+
pool = PgsqlWithPooling(config)
|
|
296
306
|
pool.open_pool()
|
|
297
307
|
with pool as (connection, cursor):
|
|
298
308
|
cursor.execute("SELECT 1")
|
|
299
309
|
|
|
300
310
|
:param config: Configuration for PostgreSQL
|
|
301
|
-
:type config:
|
|
311
|
+
:type config: PgsqlConfig
|
|
302
312
|
:param connection_timeout: Connection timeout
|
|
303
313
|
:type connection_timeout: int
|
|
304
314
|
:param instance_name: Name of the instance
|
|
@@ -310,7 +320,7 @@ class PgSQLWithPooling(DatabaseBackend):
|
|
|
310
320
|
maxconnections = 5
|
|
311
321
|
"""
|
|
312
322
|
|
|
313
|
-
config:
|
|
323
|
+
config: PgsqlConfig
|
|
314
324
|
""" Configuration """
|
|
315
325
|
|
|
316
326
|
pool: ConnectionPool[PgConnectionType]
|
|
@@ -331,7 +341,7 @@ class PgSQLWithPooling(DatabaseBackend):
|
|
|
331
341
|
|
|
332
342
|
def __init__(
|
|
333
343
|
self,
|
|
334
|
-
db_config:
|
|
344
|
+
db_config: PgsqlConfig,
|
|
335
345
|
connection_timeout: int = 5,
|
|
336
346
|
instance_name: str = "postgresql_pool",
|
|
337
347
|
) -> None:
|
|
@@ -541,7 +551,7 @@ class PgSQLWithPooling(DatabaseBackend):
|
|
|
541
551
|
self.connection.rollback()
|
|
542
552
|
|
|
543
553
|
|
|
544
|
-
class
|
|
554
|
+
class PgsqlWithPoolingAsync(DatabaseBackend):
|
|
545
555
|
"""
|
|
546
556
|
PostgreSQL database implementation with async connection pooling.
|
|
547
557
|
|
|
@@ -554,7 +564,7 @@ class PgSQLWithPoolingAsync(DatabaseBackend):
|
|
|
554
564
|
Or use context manager to get connection and return it back automatically,
|
|
555
565
|
for example:
|
|
556
566
|
|
|
557
|
-
pool =
|
|
567
|
+
pool = PgsqlWithPoolingAsync(config)
|
|
558
568
|
await pool.open_pool()
|
|
559
569
|
async with pool as (connection, cursor):
|
|
560
570
|
await cursor.execute("SELECT 1")
|
|
@@ -564,7 +574,7 @@ class PgSQLWithPoolingAsync(DatabaseBackend):
|
|
|
564
574
|
! You need to call `await close_pool()` manually in async environment.
|
|
565
575
|
|
|
566
576
|
:param config: Configuration for PostgreSQL
|
|
567
|
-
:type config:
|
|
577
|
+
:type config: PgsqlConfig
|
|
568
578
|
:param connection_timeout: Connection timeout
|
|
569
579
|
:type connection_timeout: int
|
|
570
580
|
:param instance_name: Name of the instance
|
|
@@ -576,7 +586,7 @@ class PgSQLWithPoolingAsync(DatabaseBackend):
|
|
|
576
586
|
maxconnections = 5
|
|
577
587
|
"""
|
|
578
588
|
|
|
579
|
-
config:
|
|
589
|
+
config: PgsqlConfig
|
|
580
590
|
""" Configuration """
|
|
581
591
|
|
|
582
592
|
pool_async: AsyncConnectionPool[PgConnectionTypeAsync]
|
|
@@ -597,7 +607,7 @@ class PgSQLWithPoolingAsync(DatabaseBackend):
|
|
|
597
607
|
|
|
598
608
|
def __init__(
|
|
599
609
|
self,
|
|
600
|
-
db_config:
|
|
610
|
+
db_config: PgsqlConfig,
|
|
601
611
|
connection_timeout: int = 5,
|
|
602
612
|
instance_name: str = "async_postgresql",
|
|
603
613
|
) -> None:
|
|
@@ -6,13 +6,11 @@ from psycopg import Cursor, sql
|
|
|
6
6
|
from database_wrapper import DBWrapper
|
|
7
7
|
|
|
8
8
|
from .connector import PgCursorType
|
|
9
|
-
from .db_wrapper_pgsql_mixin import
|
|
9
|
+
from .db_wrapper_pgsql_mixin import DBWrapperPgsqlMixin
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
class
|
|
13
|
-
"""
|
|
14
|
-
Sync database wrapper for postgres
|
|
15
|
-
"""
|
|
12
|
+
class DBWrapperPgsql(DBWrapperPgsqlMixin, DBWrapper):
|
|
13
|
+
"""Wrapper for PostgreSQL database"""
|
|
16
14
|
|
|
17
15
|
db_cursor: PgCursorType | None
|
|
18
16
|
""" PostgreSQL cursor object """
|
|
@@ -6,10 +6,10 @@ from psycopg import sql
|
|
|
6
6
|
from database_wrapper import DBWrapperAsync
|
|
7
7
|
|
|
8
8
|
from .connector import PgCursorTypeAsync
|
|
9
|
-
from .db_wrapper_pgsql_mixin import
|
|
9
|
+
from .db_wrapper_pgsql_mixin import DBWrapperPgsqlMixin
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
class
|
|
12
|
+
class DBWrapperPgsqlAsync(DBWrapperPgsqlMixin, DBWrapperAsync):
|
|
13
13
|
"""
|
|
14
14
|
Async database wrapper for postgres
|
|
15
15
|
|
|
@@ -5,9 +5,9 @@ from psycopg import sql
|
|
|
5
5
|
from database_wrapper import NoParam, OrderByItem
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
class
|
|
8
|
+
class DBWrapperPgsqlMixin:
|
|
9
9
|
"""
|
|
10
|
-
Mixin for providing methods that can be used by both sync and async versions of the
|
|
10
|
+
Mixin for providing methods that can be used by both sync and async versions of the DBWrapperPgsql class.
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
13
|
######################
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: database_wrapper_pgsql
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.24
|
|
4
4
|
Summary: database_wrapper for PostgreSQL database
|
|
5
5
|
Author-email: Gints Murans <gm@gm.lv>
|
|
6
6
|
License: GNU General Public License v3.0 (GPL-3.0)
|
|
@@ -32,7 +32,7 @@ Classifier: Topic :: Software Development
|
|
|
32
32
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
33
33
|
Requires-Python: >=3.8
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
|
-
Requires-Dist: database_wrapper==0.2.
|
|
35
|
+
Requires-Dist: database_wrapper==0.2.24
|
|
36
36
|
Requires-Dist: psycopg[binary]>=3.2.0
|
|
37
37
|
Requires-Dist: psycopg[pool]>=3.2.0
|
|
38
38
|
|
|
@@ -4,14 +4,12 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "database_wrapper_pgsql"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.24"
|
|
8
8
|
description = "database_wrapper for PostgreSQL database"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
11
|
-
license = {text = "GNU General Public License v3.0 (GPL-3.0)"}
|
|
12
|
-
authors = [
|
|
13
|
-
{name = "Gints Murans", email = "gm@gm.lv"}
|
|
14
|
-
]
|
|
11
|
+
license = { text = "GNU General Public License v3.0 (GPL-3.0)" }
|
|
12
|
+
authors = [{ name = "Gints Murans", email = "gm@gm.lv" }]
|
|
15
13
|
classifiers = [
|
|
16
14
|
"Development Status :: 4 - Beta",
|
|
17
15
|
"Intended Audience :: Developers",
|
|
@@ -31,11 +29,11 @@ classifiers = [
|
|
|
31
29
|
"Topic :: Database",
|
|
32
30
|
"Topic :: Database :: Front-Ends",
|
|
33
31
|
"Topic :: Software Development",
|
|
34
|
-
"Topic :: Software Development :: Libraries :: Python Modules"
|
|
32
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
35
33
|
]
|
|
36
34
|
keywords = ["database", "wrapper", "python", "postgresql", "pgsql"]
|
|
37
35
|
dependencies = [
|
|
38
|
-
"database_wrapper == 0.2.
|
|
36
|
+
"database_wrapper == 0.2.24",
|
|
39
37
|
"psycopg[binary] >= 3.2.0",
|
|
40
38
|
"psycopg[pool] >= 3.2.0",
|
|
41
39
|
]
|
|
File without changes
|
|
File without changes
|
{database_wrapper_pgsql-0.2.17 → database_wrapper_pgsql-0.2.24}/database_wrapper_pgsql/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|