database-wrapper 0.2.5__py3-none-any.whl → 0.2.7__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.
@@ -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": "9ddc494c341229d5133193ea02984ae62fde401a",
7
- "git_commit_date": "16.05.2025 22:52",
8
- "app_version": "0.2.5",
6
+ "git_commit_hash": "0bb23fda10ccaf5b4fd326e020c9bc14913fd56d",
7
+ "git_commit_date": "19.06.2025 09:18",
8
+ "app_version": "0.2.7",
9
9
  }
@@ -25,6 +25,7 @@ class MetadataDict(TypedDict):
25
25
  serialize: NotRequired[Callable[[Any], Any] | SerializeType | None]
26
26
  deserialize: NotRequired[Callable[[Any], Any] | None]
27
27
  enum_class: NotRequired[Type[Enum] | None]
28
+ timezone: NotRequired[str | datetime.tzinfo | None]
28
29
 
29
30
 
30
31
  @dataclass
@@ -137,8 +138,9 @@ class DBDataModel:
137
138
  # Here we actually need to deserialize the value to correct class type
138
139
  serialize = metadata.get("serialize", None)
139
140
  enum_class = metadata.get("enum_class", None)
141
+ timezone = metadata.get("timezone", None)
140
142
  if serialize is not None and isinstance(serialize, SerializeType):
141
- value = deserialize_value(value, serialize, enum_class)
143
+ value = deserialize_value(value, serialize, enum_class, timezone)
142
144
  setattr(self, field_name, value)
143
145
 
144
146
  else:
@@ -4,6 +4,7 @@ import json
4
4
  from decimal import Decimal
5
5
  from enum import Enum
6
6
  from typing import Any, Type
7
+ from zoneinfo import ZoneInfo
7
8
 
8
9
 
9
10
  class SerializeType(Enum):
@@ -47,6 +48,7 @@ def deserialize_value(
47
48
  value: Any,
48
49
  s_type: SerializeType,
49
50
  enum_class: Type[Enum] | None = None,
51
+ timezone: str | datetime.tzinfo | None = None,
50
52
  ) -> Any:
51
53
  if s_type == SerializeType.DATETIME:
52
54
  if isinstance(value, datetime.datetime):
@@ -57,7 +59,11 @@ def deserialize_value(
57
59
  timestamp = float(value)
58
60
  if timestamp > 1e10: # Check if timestamp is in milliseconds
59
61
  timestamp /= 1000
60
- return datetime.datetime.fromtimestamp(timestamp)
62
+
63
+ if timezone is not None and isinstance(timezone, str):
64
+ timezone = ZoneInfo(timezone)
65
+
66
+ return datetime.datetime.fromtimestamp(timestamp, tz=timezone)
61
67
 
62
68
  return datetime.datetime.fromisoformat(value)
63
69
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: database_wrapper
3
- Version: 0.2.5
3
+ Version: 0.2.7
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.5; extra == "pgsql"
36
+ Requires-Dist: database_wrapper_pgsql==0.2.7; extra == "pgsql"
37
37
  Provides-Extra: mysql
38
- Requires-Dist: database_wrapper_mysql==0.2.5; extra == "mysql"
38
+ Requires-Dist: database_wrapper_mysql==0.2.7; extra == "mysql"
39
39
  Provides-Extra: mssql
40
- Requires-Dist: database_wrapper_mssql==0.2.5; extra == "mssql"
40
+ Requires-Dist: database_wrapper_mssql==0.2.7; extra == "mssql"
41
41
  Provides-Extra: sqlite
42
- Requires-Dist: database_wrapper_sqlite==0.2.5; extra == "sqlite"
42
+ Requires-Dist: database_wrapper_sqlite==0.2.7; extra == "sqlite"
43
43
  Provides-Extra: redis
44
- Requires-Dist: database_wrapper_redis==0.2.5; extra == "redis"
44
+ Requires-Dist: database_wrapper_redis==0.2.7; 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,17 +1,17 @@
1
1
  database_wrapper/__init__.py,sha256=p-HLz9_zByIUeAS1tVxS7ZieslsryHSLw_IKZphqB7w,1200
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=4H8JPjmXN2ztrRb7idZaM8e9c1DeXlOXqc1Wx-YtEFU,333
4
+ database_wrapper/config.py,sha256=etPdRvN1X_zGxPAMclfw947h6aU-vXWWgwadMUpcJLA,333
5
5
  database_wrapper/db_backend.py,sha256=pV_XGu0tR5naz7Ni6BvpqcmN9U7TdQ0bRkg7YiNZlO0,7928
6
- database_wrapper/db_data_model.py,sha256=XCQr3Z3XMwPlISsBqjRRBSd6qt21JBN1vfJHA3S5d0A,14330
6
+ database_wrapper/db_data_model.py,sha256=w0nJ6gfHGZj9Zta31--CM7l-q9GPC-s7DCl3Es5nLxA,14450
7
7
  database_wrapper/db_wrapper.py,sha256=zwaA-5BfUhBTG3eI-Im4BKztbKN0DQLg5heIR-rbQCo,14928
8
8
  database_wrapper/db_wrapper_async.py,sha256=EnF66zOJ9BEH2tQF-5v8hywEHl8KiryDM9l610ES7O0,15244
9
9
  database_wrapper/db_wrapper_mixin.py,sha256=QCB9qjWLxeFY5f2_apJVL1rtp75spvZ1HuEApBkzID8,10071
10
10
  database_wrapper/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- database_wrapper/serialization.py,sha256=ghPEWXHdr2QAQlESCVibGxg4nd6Vr2eAvjX8E5Ub4cw,2041
11
+ database_wrapper/serialization.py,sha256=rXWNIiroDAYKyIM43_0r5N5ZaBbb59XSgzpwKzFCMMk,2250
12
12
  database_wrapper/utils/__init__.py,sha256=uC8YaJqfyFIZIeNdTRTbZwcOUVhmnS5eyOG-9gMs70c,96
13
13
  database_wrapper/utils/dataclass_addons.py,sha256=Og98FTL8_m07AjpAsbIdSkHQO099xt9asD3W2QasypY,759
14
- database_wrapper-0.2.5.dist-info/METADATA,sha256=otogCwKc8IKRzpT9P_4Dh06ZuWQSBugo5_eRuTs6Oig,3609
15
- database_wrapper-0.2.5.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
16
- database_wrapper-0.2.5.dist-info/top_level.txt,sha256=QcnS4ocJygxcKE5eoOqriuja306oVu-zJRn6yjRRhBw,17
17
- database_wrapper-0.2.5.dist-info/RECORD,,
14
+ database_wrapper-0.2.7.dist-info/METADATA,sha256=5QXWgpGRmyZMRgk9AGr2r43jp5RjrW6l-q6MvZJiQAQ,3609
15
+ database_wrapper-0.2.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ database_wrapper-0.2.7.dist-info/top_level.txt,sha256=QcnS4ocJygxcKE5eoOqriuja306oVu-zJRn6yjRRhBw,17
17
+ database_wrapper-0.2.7.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.7.1)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5