database-wrapper 0.2.9__py3-none-any.whl → 0.2.12__py3-none-any.whl
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/config.py +3 -3
- database_wrapper/db_introspector.py +2 -4
- database_wrapper/db_wrapper.py +16 -3
- database_wrapper/db_wrapper_async.py +20 -12
- {database_wrapper-0.2.9.dist-info → database_wrapper-0.2.12.dist-info}/METADATA +6 -6
- {database_wrapper-0.2.9.dist-info → database_wrapper-0.2.12.dist-info}/RECORD +8 -8
- {database_wrapper-0.2.9.dist-info → database_wrapper-0.2.12.dist-info}/WHEEL +0 -0
- {database_wrapper-0.2.9.dist-info → database_wrapper-0.2.12.dist-info}/top_level.txt +0 -0
database_wrapper/config.py
CHANGED
|
@@ -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.2.
|
|
6
|
+
"git_commit_hash": "5303fe4f402b6301865b47853111129ffdab8ee0",
|
|
7
|
+
"git_commit_date": "12.12.2025 00:45",
|
|
8
|
+
"app_version": "0.2.12",
|
|
9
9
|
}
|
|
@@ -134,9 +134,7 @@ class DBIntrospector:
|
|
|
134
134
|
# Default value choice
|
|
135
135
|
default = None
|
|
136
136
|
default_factory = None
|
|
137
|
-
if c.is_nullable:
|
|
138
|
-
default = None
|
|
139
|
-
else:
|
|
137
|
+
if c.is_nullable == False:
|
|
140
138
|
# give some sane defaults for common not-nullables that aren't id/serial
|
|
141
139
|
if py_type is bool:
|
|
142
140
|
default = False
|
|
@@ -370,7 +368,7 @@ class DBIntrospector:
|
|
|
370
368
|
|
|
371
369
|
return "\n".join(lines)
|
|
372
370
|
|
|
373
|
-
def save_to_file(self, class_model_source: str, filepath: str, overwrite: bool) -> str:
|
|
371
|
+
def save_to_file(self, class_model_source: str, filepath: str | Path, overwrite: bool) -> str:
|
|
374
372
|
"""
|
|
375
373
|
Render `cls` to a Python source file and save it to `filepath`.
|
|
376
374
|
|
database_wrapper/db_wrapper.py
CHANGED
|
@@ -281,6 +281,21 @@ class DBWrapper(DBWrapperMixin):
|
|
|
281
281
|
|
|
282
282
|
return status
|
|
283
283
|
|
|
284
|
+
def insert_data(
|
|
285
|
+
self,
|
|
286
|
+
record: DBDataModel,
|
|
287
|
+
store_data: dict[str, Any],
|
|
288
|
+
) -> tuple[int, int]:
|
|
289
|
+
status = self._insert(
|
|
290
|
+
record,
|
|
291
|
+
record.schema_name,
|
|
292
|
+
record.table_name,
|
|
293
|
+
store_data,
|
|
294
|
+
record.id_key,
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
return status
|
|
298
|
+
|
|
284
299
|
def _update(
|
|
285
300
|
self,
|
|
286
301
|
empty_data_class: DBDataModel,
|
|
@@ -308,9 +323,7 @@ class DBWrapper(DBWrapperMixin):
|
|
|
308
323
|
|
|
309
324
|
table_identifier = self.make_identifier(schema_name, table_name)
|
|
310
325
|
update_key = self.make_identifier(empty_data_class.table_alias, id_key)
|
|
311
|
-
update_query = self._format_update_query(
|
|
312
|
-
table_identifier, update_key, update_data
|
|
313
|
-
)
|
|
326
|
+
update_query = self._format_update_query(table_identifier, update_key, update_data)
|
|
314
327
|
|
|
315
328
|
# Log
|
|
316
329
|
self.log_query(self.db_cursor, update_query, tuple(values))
|
|
@@ -41,7 +41,7 @@ class DBWrapperAsync(DBWrapperMixin):
|
|
|
41
41
|
raise ValueError("Id value is not set")
|
|
42
42
|
|
|
43
43
|
# Get the record
|
|
44
|
-
res = self.
|
|
44
|
+
res = self.get_all(
|
|
45
45
|
empty_data_class,
|
|
46
46
|
id_key,
|
|
47
47
|
id_value,
|
|
@@ -73,7 +73,7 @@ class DBWrapperAsync(DBWrapperMixin):
|
|
|
73
73
|
DataModelType | None: The result of the query.
|
|
74
74
|
"""
|
|
75
75
|
# Get the record
|
|
76
|
-
res = self.
|
|
76
|
+
res = self.get_all(
|
|
77
77
|
empty_data_class,
|
|
78
78
|
id_key,
|
|
79
79
|
id_value,
|
|
@@ -85,7 +85,7 @@ class DBWrapperAsync(DBWrapperMixin):
|
|
|
85
85
|
else:
|
|
86
86
|
return None
|
|
87
87
|
|
|
88
|
-
async def
|
|
88
|
+
async def get_all(
|
|
89
89
|
self,
|
|
90
90
|
empty_data_class: DataModelType,
|
|
91
91
|
id_key: str | None = None,
|
|
@@ -283,6 +283,20 @@ class DBWrapperAsync(DBWrapperMixin):
|
|
|
283
283
|
|
|
284
284
|
return status
|
|
285
285
|
|
|
286
|
+
async def insert_data(
|
|
287
|
+
self,
|
|
288
|
+
record: DBDataModel,
|
|
289
|
+
store_data: dict[str, Any],
|
|
290
|
+
) -> tuple[int, int]:
|
|
291
|
+
status = await self._insert(
|
|
292
|
+
record,
|
|
293
|
+
record.schema_name,
|
|
294
|
+
record.table_name,
|
|
295
|
+
store_data,
|
|
296
|
+
record.id_key,
|
|
297
|
+
)
|
|
298
|
+
return status
|
|
299
|
+
|
|
286
300
|
async def _update(
|
|
287
301
|
self,
|
|
288
302
|
empty_data_class: DBDataModel,
|
|
@@ -310,9 +324,7 @@ class DBWrapperAsync(DBWrapperMixin):
|
|
|
310
324
|
|
|
311
325
|
table_identifier = self.make_identifier(schema_name, table_name)
|
|
312
326
|
update_key = self.make_identifier(empty_data_class.table_alias, id_key)
|
|
313
|
-
update_query = self._format_update_query(
|
|
314
|
-
table_identifier, update_key, update_data
|
|
315
|
-
)
|
|
327
|
+
update_query = self._format_update_query(table_identifier, update_key, update_data)
|
|
316
328
|
|
|
317
329
|
# Log
|
|
318
330
|
self.log_query(self.db_cursor, update_query, tuple(values))
|
|
@@ -330,9 +342,7 @@ class DBWrapperAsync(DBWrapperMixin):
|
|
|
330
342
|
@overload
|
|
331
343
|
async def update(self, records: list[DataModelType]) -> list[int]: ...
|
|
332
344
|
|
|
333
|
-
async def update(
|
|
334
|
-
self, records: DataModelType | list[DataModelType]
|
|
335
|
-
) -> int | list[int]:
|
|
345
|
+
async def update(self, records: DataModelType | list[DataModelType]) -> int | list[int]:
|
|
336
346
|
"""
|
|
337
347
|
Updates a record or a list of records in the database.
|
|
338
348
|
|
|
@@ -438,9 +448,7 @@ class DBWrapperAsync(DBWrapperMixin):
|
|
|
438
448
|
@overload
|
|
439
449
|
async def delete(self, records: list[DataModelType]) -> list[int]: ...
|
|
440
450
|
|
|
441
|
-
async def delete(
|
|
442
|
-
self, records: DataModelType | list[DataModelType]
|
|
443
|
-
) -> int | list[int]:
|
|
451
|
+
async def delete(self, records: DataModelType | list[DataModelType]) -> int | list[int]:
|
|
444
452
|
"""
|
|
445
453
|
Deletes a record or a list of records from the database.
|
|
446
454
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: database_wrapper
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.12
|
|
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,15 +33,15 @@ 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.2.
|
|
36
|
+
Requires-Dist: database_wrapper_pgsql==0.2.12; extra == "pgsql"
|
|
37
37
|
Provides-Extra: mysql
|
|
38
|
-
Requires-Dist: database_wrapper_mysql==0.2.
|
|
38
|
+
Requires-Dist: database_wrapper_mysql==0.2.12; extra == "mysql"
|
|
39
39
|
Provides-Extra: mssql
|
|
40
|
-
Requires-Dist: database_wrapper_mssql==0.2.
|
|
40
|
+
Requires-Dist: database_wrapper_mssql==0.2.12; extra == "mssql"
|
|
41
41
|
Provides-Extra: sqlite
|
|
42
|
-
Requires-Dist: database_wrapper_sqlite==0.2.
|
|
42
|
+
Requires-Dist: database_wrapper_sqlite==0.2.12; extra == "sqlite"
|
|
43
43
|
Provides-Extra: redis
|
|
44
|
-
Requires-Dist: database_wrapper_redis==0.2.
|
|
44
|
+
Requires-Dist: database_wrapper_redis==0.2.12; extra == "redis"
|
|
45
45
|
Provides-Extra: all
|
|
46
46
|
Requires-Dist: database_wrapper[mssql,mysql,pgsql,redis,sqlite]; extra == "all"
|
|
47
47
|
Provides-Extra: dev
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
database_wrapper/__init__.py,sha256=cGqsWr7imdMOO7vrcGye8FVul_v3-32mw4wgrfxnhJA,1320
|
|
2
2
|
database_wrapper/abc.py,sha256=JiQo6Yfv7xALrrHeICJCSgmyP2gHrp16Ov83mPBTGbE,2058
|
|
3
3
|
database_wrapper/common.py,sha256=fsxe28o_4xCrotPbB274dmzQ9rOyes0sBtcHog-9RVc,258
|
|
4
|
-
database_wrapper/config.py,sha256=
|
|
4
|
+
database_wrapper/config.py,sha256=fd0r4jBxWyqKp5YR4b44sS0jkWlKNi7m-2DrU0QI7hg,334
|
|
5
5
|
database_wrapper/db_backend.py,sha256=pV_XGu0tR5naz7Ni6BvpqcmN9U7TdQ0bRkg7YiNZlO0,7928
|
|
6
6
|
database_wrapper/db_data_model.py,sha256=6yMArPQPfbiFn9GvfRKYQzEh67LfaUn7JqkKTTCc7W8,14888
|
|
7
|
-
database_wrapper/db_introspector.py,sha256=
|
|
8
|
-
database_wrapper/db_wrapper.py,sha256=
|
|
9
|
-
database_wrapper/db_wrapper_async.py,sha256=
|
|
7
|
+
database_wrapper/db_introspector.py,sha256=8sWNmBeumCE0D-cbpBvpMSTbCU6dpDLxCPB8HaNf6KA,15463
|
|
8
|
+
database_wrapper/db_wrapper.py,sha256=x6xsMW0epCOaj3RWWi9mj1EE1JmqM27PyS_Khvsxdvo,15231
|
|
9
|
+
database_wrapper/db_wrapper_async.py,sha256=ud7kCDfsfrbp3FHfRS7FjbsVTnnf87sHsxctpNWuhnk,15500
|
|
10
10
|
database_wrapper/db_wrapper_mixin.py,sha256=QCB9qjWLxeFY5f2_apJVL1rtp75spvZ1HuEApBkzID8,10071
|
|
11
11
|
database_wrapper/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
database_wrapper/serialization.py,sha256=Tti1-nA7H4g3hzqr3mE2WurxOnEjFaxBJZTOR3ONZSo,2906
|
|
13
13
|
database_wrapper/utils/__init__.py,sha256=uC8YaJqfyFIZIeNdTRTbZwcOUVhmnS5eyOG-9gMs70c,96
|
|
14
14
|
database_wrapper/utils/dataclass_addons.py,sha256=Og98FTL8_m07AjpAsbIdSkHQO099xt9asD3W2QasypY,759
|
|
15
|
-
database_wrapper-0.2.
|
|
16
|
-
database_wrapper-0.2.
|
|
17
|
-
database_wrapper-0.2.
|
|
18
|
-
database_wrapper-0.2.
|
|
15
|
+
database_wrapper-0.2.12.dist-info/METADATA,sha256=9OY4mmgQrEsXSrbe2wumawhKi2TdKCIBxXwztFQHG4Y,3615
|
|
16
|
+
database_wrapper-0.2.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
17
|
+
database_wrapper-0.2.12.dist-info/top_level.txt,sha256=QcnS4ocJygxcKE5eoOqriuja306oVu-zJRn6yjRRhBw,17
|
|
18
|
+
database_wrapper-0.2.12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|