database-wrapper 0.1.87__tar.gz → 0.1.89__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-0.1.87 → database_wrapper-0.1.89}/PKG-INFO +5 -5
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper/config.py +3 -3
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper/db_backend.py +16 -12
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper/db_data_model.py +10 -1
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper/db_wrapper.py +5 -5
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper/db_wrapper_async.py +5 -5
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper.egg-info/PKG-INFO +5 -5
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper.egg-info/requires.txt +4 -4
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/pyproject.toml +5 -5
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/README.md +0 -0
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper/__init__.py +0 -0
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper/abc.py +0 -0
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper/common.py +0 -0
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper/db_wrapper_mixin.py +0 -0
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper/py.typed +0 -0
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper/serialization.py +0 -0
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper/utils/__init__.py +0 -0
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper/utils/dataclass_addons.py +0 -0
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper.egg-info/SOURCES.txt +0 -0
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper.egg-info/dependency_links.txt +0 -0
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper.egg-info/top_level.txt +0 -0
- {database_wrapper-0.1.87 → database_wrapper-0.1.89}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: database_wrapper
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.89
|
|
4
4
|
Summary: A Different Approach to Database Wrappers in Python
|
|
5
5
|
Author-email: Gints Murans <gm@gm.lv>
|
|
6
6
|
License: GNU General Public License v3.0 (GPL-3.0)
|
|
@@ -33,13 +33,13 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
33
33
|
Requires-Python: >=3.8
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
35
|
Provides-Extra: pgsql
|
|
36
|
-
Requires-Dist: database_wrapper_pgsql==0.1.
|
|
36
|
+
Requires-Dist: database_wrapper_pgsql==0.1.89; extra == "pgsql"
|
|
37
37
|
Provides-Extra: mysql
|
|
38
|
-
Requires-Dist: database_wrapper_mysql==0.1.
|
|
38
|
+
Requires-Dist: database_wrapper_mysql==0.1.89; extra == "mysql"
|
|
39
39
|
Provides-Extra: mssql
|
|
40
|
-
Requires-Dist: database_wrapper_mssql==0.1.
|
|
40
|
+
Requires-Dist: database_wrapper_mssql==0.1.89; extra == "mssql"
|
|
41
41
|
Provides-Extra: sqlite
|
|
42
|
-
Requires-Dist: database_wrapper_sqlite==0.1.
|
|
42
|
+
Requires-Dist: database_wrapper_sqlite==0.1.89; extra == "sqlite"
|
|
43
43
|
Provides-Extra: all
|
|
44
44
|
Requires-Dist: database_wrapper[mssql,mysql,pgsql,sqlite]; extra == "all"
|
|
45
45
|
Provides-Extra: dev
|
|
@@ -3,7 +3,7 @@ from typing import Any
|
|
|
3
3
|
CONFIG: dict[str, Any] = {
|
|
4
4
|
# These are supposed to be set automatically by a git pre-compile script
|
|
5
5
|
# They are one git commit hash behind, if used automatically
|
|
6
|
-
"git_commit_hash": "
|
|
7
|
-
"git_commit_date": "
|
|
8
|
-
"app_version": "0.1.
|
|
6
|
+
"git_commit_hash": "767ed2a4545cb72fbb54657ef4c51c0bdab5b5f4",
|
|
7
|
+
"git_commit_date": "04.02.2026 14:22",
|
|
8
|
+
"app_version": "0.1.89",
|
|
9
9
|
}
|
|
@@ -90,9 +90,7 @@ class DatabaseBackend:
|
|
|
90
90
|
self.cursor = None
|
|
91
91
|
self.shutdownRequested = Event()
|
|
92
92
|
self.contextConnection = ContextVar(f"db_connection_{self.name}", default=None)
|
|
93
|
-
self.contextConnectionAsync = ContextVar(
|
|
94
|
-
f"db_connection_{self.name}_async", default=None
|
|
95
|
-
)
|
|
93
|
+
self.contextConnectionAsync = ContextVar(f"db_connection_{self.name}_async", default=None)
|
|
96
94
|
|
|
97
95
|
def __del__(self) -> None:
|
|
98
96
|
"""What to do when class is destroyed"""
|
|
@@ -147,14 +145,22 @@ class DatabaseBackend:
|
|
|
147
145
|
|
|
148
146
|
def close(self) -> Any:
|
|
149
147
|
"""Close connections"""
|
|
150
|
-
|
|
151
|
-
self.
|
|
152
|
-
|
|
148
|
+
try:
|
|
149
|
+
if self.cursor:
|
|
150
|
+
self.logger.debug("Closing cursor")
|
|
151
|
+
self.cursor.close()
|
|
152
|
+
except Exception as e:
|
|
153
|
+
self.logger.debug(f"Error while closing cursor: {e}")
|
|
154
|
+
finally:
|
|
153
155
|
self.cursor = None
|
|
154
156
|
|
|
155
|
-
|
|
156
|
-
self.
|
|
157
|
-
|
|
157
|
+
try:
|
|
158
|
+
if self.connection:
|
|
159
|
+
self.logger.debug("Closing connection")
|
|
160
|
+
self.connection.close()
|
|
161
|
+
except Exception as e:
|
|
162
|
+
self.logger.debug(f"Error while closing connection: {e}")
|
|
163
|
+
finally:
|
|
158
164
|
self.connection = None
|
|
159
165
|
|
|
160
166
|
def newConnection(self) -> Any:
|
|
@@ -227,9 +233,7 @@ class DatabaseBackend:
|
|
|
227
233
|
s.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 3)
|
|
228
234
|
# To set timeout for an RTO you must set TCP_USER_TIMEOUT timeout
|
|
229
235
|
# (in milliseconds) for socket.
|
|
230
|
-
s.setsockopt(
|
|
231
|
-
socket.IPPROTO_TCP, socket.TCP_USER_TIMEOUT, self.connectionTimeout * 1000
|
|
232
|
-
)
|
|
236
|
+
s.setsockopt(socket.IPPROTO_TCP, socket.TCP_USER_TIMEOUT, self.connectionTimeout * 1000)
|
|
233
237
|
|
|
234
238
|
####################
|
|
235
239
|
### Transactions ###
|
|
@@ -163,7 +163,7 @@ class DBDataModel:
|
|
|
163
163
|
classField = self.__dataclass_fields__.get(field[0], None)
|
|
164
164
|
if classField is not None:
|
|
165
165
|
metadata = cast(MetadataDict, classField.metadata)
|
|
166
|
-
if
|
|
166
|
+
if "exclude" not in metadata or not metadata["exclude"]:
|
|
167
167
|
newDict[field[0]] = field[1]
|
|
168
168
|
|
|
169
169
|
return newDict
|
|
@@ -294,6 +294,15 @@ class DBDataModel:
|
|
|
294
294
|
currentMetadata["exclude"] = enable
|
|
295
295
|
self.__dataclass_fields__[fieldName].metadata = currentMetadata
|
|
296
296
|
|
|
297
|
+
def setIdValue(self, idValue: Any) -> None:
|
|
298
|
+
"""
|
|
299
|
+
Set the value of the primary key for the current instance.
|
|
300
|
+
|
|
301
|
+
Args:
|
|
302
|
+
idValue (Any): The value to set for the primary key.
|
|
303
|
+
"""
|
|
304
|
+
setattr(self, self.idKey, idValue)
|
|
305
|
+
|
|
297
306
|
########################
|
|
298
307
|
### Database methods ###
|
|
299
308
|
########################
|
|
@@ -32,7 +32,7 @@ class DBWrapper(DBWrapperMixin):
|
|
|
32
32
|
"""
|
|
33
33
|
# Figure out the id key and value
|
|
34
34
|
idKey = emptyDataClass.idKey
|
|
35
|
-
idValue = emptyDataClass.
|
|
35
|
+
idValue = emptyDataClass.idValue
|
|
36
36
|
if not idKey:
|
|
37
37
|
raise ValueError("Id key is not set")
|
|
38
38
|
if not idValue:
|
|
@@ -254,7 +254,7 @@ class DBWrapper(DBWrapperMixin):
|
|
|
254
254
|
storeIdKey,
|
|
255
255
|
)
|
|
256
256
|
if res:
|
|
257
|
-
row
|
|
257
|
+
setattr(row, storeIdKey, res[0]) # update the id of the row
|
|
258
258
|
|
|
259
259
|
status.append(res)
|
|
260
260
|
|
|
@@ -329,7 +329,7 @@ class DBWrapper(DBWrapperMixin):
|
|
|
329
329
|
for row in records:
|
|
330
330
|
updateData = row.updateData()
|
|
331
331
|
updateIdKey = row.idKey
|
|
332
|
-
updateIdValue = row.
|
|
332
|
+
updateIdValue = row.idValue
|
|
333
333
|
if not updateData or not updateIdKey or not updateIdValue:
|
|
334
334
|
continue
|
|
335
335
|
|
|
@@ -359,7 +359,7 @@ class DBWrapper(DBWrapperMixin):
|
|
|
359
359
|
updateIdValue: Any = None,
|
|
360
360
|
) -> int:
|
|
361
361
|
updateIdKey = updateIdKey or record.idKey
|
|
362
|
-
updateIdValue = updateIdValue or record.
|
|
362
|
+
updateIdValue = updateIdValue or record.idValue
|
|
363
363
|
status = self._update(
|
|
364
364
|
record,
|
|
365
365
|
record.schemaName,
|
|
@@ -434,7 +434,7 @@ class DBWrapper(DBWrapperMixin):
|
|
|
434
434
|
|
|
435
435
|
for row in records:
|
|
436
436
|
deleteIdKey = row.idKey
|
|
437
|
-
deleteIdValue = row.
|
|
437
|
+
deleteIdValue = row.idValue
|
|
438
438
|
if not deleteIdKey or not deleteIdValue:
|
|
439
439
|
continue
|
|
440
440
|
|
|
@@ -34,7 +34,7 @@ class DBWrapperAsync(DBWrapperMixin):
|
|
|
34
34
|
"""
|
|
35
35
|
# Figure out the id key and value
|
|
36
36
|
idKey = emptyDataClass.idKey
|
|
37
|
-
idValue = emptyDataClass.
|
|
37
|
+
idValue = emptyDataClass.idValue
|
|
38
38
|
if not idKey:
|
|
39
39
|
raise ValueError("Id key is not set")
|
|
40
40
|
if not idValue:
|
|
@@ -264,7 +264,7 @@ class DBWrapperAsync(DBWrapperMixin):
|
|
|
264
264
|
storeIdKey,
|
|
265
265
|
)
|
|
266
266
|
if res:
|
|
267
|
-
row
|
|
267
|
+
setattr(row, storeIdKey, res[0]) # update the id of the row
|
|
268
268
|
|
|
269
269
|
status.append(res)
|
|
270
270
|
|
|
@@ -341,7 +341,7 @@ class DBWrapperAsync(DBWrapperMixin):
|
|
|
341
341
|
for row in records:
|
|
342
342
|
updateData = row.updateData()
|
|
343
343
|
updateIdKey = row.idKey
|
|
344
|
-
updateIdValue = row.
|
|
344
|
+
updateIdValue = row.idValue
|
|
345
345
|
if not updateData or not updateIdKey or not updateIdValue:
|
|
346
346
|
continue
|
|
347
347
|
|
|
@@ -371,7 +371,7 @@ class DBWrapperAsync(DBWrapperMixin):
|
|
|
371
371
|
updateIdValue: Any = None,
|
|
372
372
|
) -> int:
|
|
373
373
|
updateIdKey = updateIdKey or record.idKey
|
|
374
|
-
updateIdValue = updateIdValue or record.
|
|
374
|
+
updateIdValue = updateIdValue or record.idValue
|
|
375
375
|
status = await self._update(
|
|
376
376
|
record,
|
|
377
377
|
record.schemaName,
|
|
@@ -448,7 +448,7 @@ class DBWrapperAsync(DBWrapperMixin):
|
|
|
448
448
|
|
|
449
449
|
for row in records:
|
|
450
450
|
deleteIdKey = row.idKey
|
|
451
|
-
deleteIdValue = row.
|
|
451
|
+
deleteIdValue = row.idValue
|
|
452
452
|
if not deleteIdKey or not deleteIdValue:
|
|
453
453
|
continue
|
|
454
454
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: database_wrapper
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.89
|
|
4
4
|
Summary: A Different Approach to Database Wrappers in Python
|
|
5
5
|
Author-email: Gints Murans <gm@gm.lv>
|
|
6
6
|
License: GNU General Public License v3.0 (GPL-3.0)
|
|
@@ -33,13 +33,13 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
33
33
|
Requires-Python: >=3.8
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
35
|
Provides-Extra: pgsql
|
|
36
|
-
Requires-Dist: database_wrapper_pgsql==0.1.
|
|
36
|
+
Requires-Dist: database_wrapper_pgsql==0.1.89; extra == "pgsql"
|
|
37
37
|
Provides-Extra: mysql
|
|
38
|
-
Requires-Dist: database_wrapper_mysql==0.1.
|
|
38
|
+
Requires-Dist: database_wrapper_mysql==0.1.89; extra == "mysql"
|
|
39
39
|
Provides-Extra: mssql
|
|
40
|
-
Requires-Dist: database_wrapper_mssql==0.1.
|
|
40
|
+
Requires-Dist: database_wrapper_mssql==0.1.89; extra == "mssql"
|
|
41
41
|
Provides-Extra: sqlite
|
|
42
|
-
Requires-Dist: database_wrapper_sqlite==0.1.
|
|
42
|
+
Requires-Dist: database_wrapper_sqlite==0.1.89; extra == "sqlite"
|
|
43
43
|
Provides-Extra: all
|
|
44
44
|
Requires-Dist: database_wrapper[mssql,mysql,pgsql,sqlite]; extra == "all"
|
|
45
45
|
Provides-Extra: dev
|
|
@@ -17,13 +17,13 @@ mysqlclient>=2.2.2
|
|
|
17
17
|
pymssql>=2.2.10
|
|
18
18
|
|
|
19
19
|
[mssql]
|
|
20
|
-
database_wrapper_mssql==0.1.
|
|
20
|
+
database_wrapper_mssql==0.1.89
|
|
21
21
|
|
|
22
22
|
[mysql]
|
|
23
|
-
database_wrapper_mysql==0.1.
|
|
23
|
+
database_wrapper_mysql==0.1.89
|
|
24
24
|
|
|
25
25
|
[pgsql]
|
|
26
|
-
database_wrapper_pgsql==0.1.
|
|
26
|
+
database_wrapper_pgsql==0.1.89
|
|
27
27
|
|
|
28
28
|
[sqlite]
|
|
29
|
-
database_wrapper_sqlite==0.1.
|
|
29
|
+
database_wrapper_sqlite==0.1.89
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "database_wrapper"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.89"
|
|
8
8
|
description = "A Different Approach to Database Wrappers in Python"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -45,10 +45,10 @@ Code = "https://github.com/gintsmurans/py_database_wrapper"
|
|
|
45
45
|
Download = "https://pypi.org/project/database_wrapper/"
|
|
46
46
|
|
|
47
47
|
[project.optional-dependencies]
|
|
48
|
-
pgsql = ["database_wrapper_pgsql == 0.1.
|
|
49
|
-
mysql = ["database_wrapper_mysql == 0.1.
|
|
50
|
-
mssql = ["database_wrapper_mssql == 0.1.
|
|
51
|
-
sqlite = ["database_wrapper_sqlite == 0.1.
|
|
48
|
+
pgsql = ["database_wrapper_pgsql == 0.1.89"]
|
|
49
|
+
mysql = ["database_wrapper_mysql == 0.1.89"]
|
|
50
|
+
mssql = ["database_wrapper_mssql == 0.1.89"]
|
|
51
|
+
sqlite = ["database_wrapper_sqlite == 0.1.89"]
|
|
52
52
|
all = ["database_wrapper[pgsql,mysql,mssql,sqlite]"]
|
|
53
53
|
dev = [
|
|
54
54
|
# Development
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper/utils/dataclass_addons.py
RENAMED
|
File without changes
|
|
File without changes
|
{database_wrapper-0.1.87 → database_wrapper-0.1.89}/database_wrapper.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|