database-wrapper-pgsql 0.1.38__tar.gz → 0.1.42__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.1.38 → database_wrapper_pgsql-0.1.42}/PKG-INFO +2 -2
- {database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/database_wrapper_pgsql/db_wrapper_pgsql.py +12 -9
- {database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/database_wrapper_pgsql/db_wrapper_pgsql_async.py +15 -9
- {database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/database_wrapper_pgsql/db_wrapper_pgsql_mixin.py +22 -1
- {database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/database_wrapper_pgsql.egg-info/PKG-INFO +2 -2
- {database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/database_wrapper_pgsql.egg-info/requires.txt +1 -1
- {database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/pyproject.toml +2 -2
- {database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/README.md +0 -0
- {database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/database_wrapper_pgsql/__init__.py +0 -0
- {database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/database_wrapper_pgsql/connector.py +0 -0
- {database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/database_wrapper_pgsql/py.typed +0 -0
- {database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/database_wrapper_pgsql.egg-info/SOURCES.txt +0 -0
- {database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/database_wrapper_pgsql.egg-info/dependency_links.txt +0 -0
- {database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/database_wrapper_pgsql.egg-info/top_level.txt +0 -0
- {database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: database_wrapper_pgsql
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.42
|
|
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.1.
|
|
35
|
+
Requires-Dist: database_wrapper==0.1.42
|
|
36
36
|
Requires-Dist: psycopg[binary]>=3.2.0
|
|
37
37
|
Requires-Dist: psycopg[pool]>=3.2.0
|
|
38
38
|
|
|
@@ -21,7 +21,7 @@ class DBWrapperPgSQL(DBWrapperPgSQLMixin, DBWrapper):
|
|
|
21
21
|
"""
|
|
22
22
|
|
|
23
23
|
# Override db instance
|
|
24
|
-
db: PgSQL
|
|
24
|
+
db: PgSQL | None = None
|
|
25
25
|
""" PostgreSQL database connector """
|
|
26
26
|
|
|
27
27
|
dbConn: PgConnectionType | None = None
|
|
@@ -53,23 +53,23 @@ class DBWrapperPgSQL(DBWrapperPgSQLMixin, DBWrapper):
|
|
|
53
53
|
### Setters ###
|
|
54
54
|
###############
|
|
55
55
|
|
|
56
|
-
def
|
|
56
|
+
def setDb(self, db: PgSQL | None) -> None:
|
|
57
57
|
"""
|
|
58
58
|
Updates the database backend object.
|
|
59
59
|
|
|
60
60
|
Args:
|
|
61
|
-
db (
|
|
61
|
+
db (PgSQL | None): The new database backend object.
|
|
62
62
|
"""
|
|
63
|
-
|
|
63
|
+
super().setDb(db)
|
|
64
64
|
|
|
65
|
-
def
|
|
65
|
+
def setDbConn(self, dbConn: PgConnectionType | None) -> None:
|
|
66
66
|
"""
|
|
67
67
|
Updates the database connection object.
|
|
68
68
|
|
|
69
69
|
Args:
|
|
70
|
-
dbConn (
|
|
70
|
+
dbConn (PgConnectionType | None): The new database connection object.
|
|
71
71
|
"""
|
|
72
|
-
|
|
72
|
+
super().setDbConn(dbConn)
|
|
73
73
|
|
|
74
74
|
######################
|
|
75
75
|
### Helper methods ###
|
|
@@ -98,10 +98,13 @@ class DBWrapperPgSQL(DBWrapperPgSQLMixin, DBWrapper):
|
|
|
98
98
|
Returns:
|
|
99
99
|
PgAsyncCursorType | AsyncCursor[DBDataModel]: The created cursor object.
|
|
100
100
|
"""
|
|
101
|
-
|
|
101
|
+
if self.db is None and self.dbConn is None:
|
|
102
|
+
raise ValueError(
|
|
103
|
+
"Database object and connection is not properly initialized"
|
|
104
|
+
)
|
|
102
105
|
|
|
103
106
|
# First we need connection
|
|
104
|
-
if self.dbConn is None:
|
|
107
|
+
if self.dbConn is None and self.db is not None:
|
|
105
108
|
self.dbConn = self.db.connection
|
|
106
109
|
|
|
107
110
|
# Lets make sure we have a connection
|
|
@@ -24,7 +24,7 @@ class DBWrapperPgSQLAsync(DBWrapperPgSQLMixin, DBWrapperAsync):
|
|
|
24
24
|
"""
|
|
25
25
|
|
|
26
26
|
# Override db instance
|
|
27
|
-
db: PgSQLWithPoolingAsync
|
|
27
|
+
db: PgSQLWithPoolingAsync | None = None
|
|
28
28
|
""" Async PostgreSQL database connector """
|
|
29
29
|
|
|
30
30
|
dbConn: PgAsyncConnectionType | None = None
|
|
@@ -62,23 +62,23 @@ class DBWrapperPgSQLAsync(DBWrapperPgSQLMixin, DBWrapperAsync):
|
|
|
62
62
|
### Setters ###
|
|
63
63
|
###############
|
|
64
64
|
|
|
65
|
-
def
|
|
65
|
+
def setDb(self, db: PgSQLWithPoolingAsync | None) -> None:
|
|
66
66
|
"""
|
|
67
67
|
Updates the database backend object.
|
|
68
68
|
|
|
69
69
|
Args:
|
|
70
|
-
db (
|
|
70
|
+
db (PgSQLWithPoolingAsync | None): The new database backend object.
|
|
71
71
|
"""
|
|
72
|
-
|
|
72
|
+
super().setDb(db)
|
|
73
73
|
|
|
74
|
-
def
|
|
74
|
+
def setDbConn(self, dbConn: PgAsyncConnectionType | None) -> None:
|
|
75
75
|
"""
|
|
76
76
|
Updates the database connection object.
|
|
77
77
|
|
|
78
78
|
Args:
|
|
79
|
-
dbConn (
|
|
79
|
+
dbConn (PgAsyncConnectionType | None): The new database connection object.
|
|
80
80
|
"""
|
|
81
|
-
|
|
81
|
+
super().setDbConn(dbConn)
|
|
82
82
|
|
|
83
83
|
######################
|
|
84
84
|
### Helper methods ###
|
|
@@ -107,10 +107,13 @@ class DBWrapperPgSQLAsync(DBWrapperPgSQLMixin, DBWrapperAsync):
|
|
|
107
107
|
Returns:
|
|
108
108
|
PgAsyncCursorType | AsyncCursor[DBDataModel]: The created cursor object.
|
|
109
109
|
"""
|
|
110
|
-
|
|
110
|
+
if self.db is None and self.dbConn is None:
|
|
111
|
+
raise ValueError(
|
|
112
|
+
"Database object and connection is not properly initialized"
|
|
113
|
+
)
|
|
111
114
|
|
|
112
115
|
# First we need connection
|
|
113
|
-
if self.dbConn is None:
|
|
116
|
+
if self.dbConn is None and self.db is not None:
|
|
114
117
|
status = await self.db.newConnection()
|
|
115
118
|
if not status:
|
|
116
119
|
raise Exception("Failed to create new connection")
|
|
@@ -118,6 +121,9 @@ class DBWrapperPgSQLAsync(DBWrapperPgSQLMixin, DBWrapperAsync):
|
|
|
118
121
|
(pgConn, _pgCur) = status
|
|
119
122
|
self.dbConn = pgConn
|
|
120
123
|
|
|
124
|
+
if self.dbConn is None:
|
|
125
|
+
raise Exception("Failed to get connection")
|
|
126
|
+
|
|
121
127
|
if emptyDataClass is None:
|
|
122
128
|
return self.dbConn.cursor()
|
|
123
129
|
|
|
@@ -2,7 +2,7 @@ from typing import Any, cast
|
|
|
2
2
|
|
|
3
3
|
from psycopg import sql
|
|
4
4
|
|
|
5
|
-
from database_wrapper import OrderByItem, DataModelType
|
|
5
|
+
from database_wrapper import OrderByItem, DataModelType, NoParam
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class DBWrapperPgSQLMixin:
|
|
@@ -106,6 +106,25 @@ class DBWrapperPgSQLMixin:
|
|
|
106
106
|
|
|
107
107
|
return sql.SQL("LIMIT {} OFFSET {}").format(limit, offset)
|
|
108
108
|
|
|
109
|
+
def formatFilter(self, key: str, filter: Any) -> tuple[Any, ...]:
|
|
110
|
+
# TODO: For now we assume that we have that method from DBWrapperMixin
|
|
111
|
+
# TODO: Its 5am and I am tired, I will fix this later
|
|
112
|
+
return super().formatFilter(key, filter) # type: ignore
|
|
113
|
+
|
|
114
|
+
def createFilter(
|
|
115
|
+
self, filter: dict[str, Any] | None
|
|
116
|
+
) -> tuple[sql.Composed | None, tuple[Any, ...]]:
|
|
117
|
+
if filter is None or len(filter) == 0:
|
|
118
|
+
return (None, tuple())
|
|
119
|
+
|
|
120
|
+
raw = [self.formatFilter(key, filter[key]) for key in filter]
|
|
121
|
+
|
|
122
|
+
_queryItems = sql.SQL(" AND ").join([sql.SQL(tup[0]) for tup in raw])
|
|
123
|
+
_query = sql.SQL("WHERE {queryItems}").format(queryItems=_queryItems)
|
|
124
|
+
_params = tuple([val for tup in raw for val in tup[1:] if val is not NoParam])
|
|
125
|
+
|
|
126
|
+
return (_query, _params)
|
|
127
|
+
|
|
109
128
|
def _formatFilterQuery(
|
|
110
129
|
self,
|
|
111
130
|
query: sql.SQL | sql.Composed | str,
|
|
@@ -119,6 +138,8 @@ class DBWrapperPgSQLMixin:
|
|
|
119
138
|
|
|
120
139
|
queryParts: list[sql.Composable] = [query]
|
|
121
140
|
if qFilter is not None:
|
|
141
|
+
# if isinstance(qFilter, str):
|
|
142
|
+
# qFilter = sql.SQL(qFilter)
|
|
122
143
|
queryParts.append(qFilter)
|
|
123
144
|
if order is not None:
|
|
124
145
|
queryParts.append(order)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: database_wrapper_pgsql
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.42
|
|
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.1.
|
|
35
|
+
Requires-Dist: database_wrapper==0.1.42
|
|
36
36
|
Requires-Dist: psycopg[binary]>=3.2.0
|
|
37
37
|
Requires-Dist: psycopg[pool]>=3.2.0
|
|
38
38
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "database_wrapper_pgsql"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.42"
|
|
8
8
|
description = "database_wrapper for PostgreSQL database"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -35,7 +35,7 @@ classifiers = [
|
|
|
35
35
|
]
|
|
36
36
|
keywords = ["database", "wrapper", "python", "postgresql", "pgsql"]
|
|
37
37
|
dependencies = [
|
|
38
|
-
"database_wrapper == 0.1.
|
|
38
|
+
"database_wrapper == 0.1.42",
|
|
39
39
|
"psycopg[binary] >= 3.2.0",
|
|
40
40
|
"psycopg[pool] >= 3.2.0",
|
|
41
41
|
]
|
|
File without changes
|
{database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/database_wrapper_pgsql/__init__.py
RENAMED
|
File without changes
|
{database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/database_wrapper_pgsql/connector.py
RENAMED
|
File without changes
|
{database_wrapper_pgsql-0.1.38 → database_wrapper_pgsql-0.1.42}/database_wrapper_pgsql/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|