slinn-orm 0.0.5__tar.gz → 0.0.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: slinn-orm
3
- Version: 0.0.5
3
+ Version: 0.0.6
4
4
  Summary: ORM for Slinn
5
5
  Author-email: Mark Radin <openmiot@gmail.com>
6
6
  Requires-Python: >=3.14
@@ -48,3 +48,13 @@ class PoolProtocol(Protocol):
48
48
 
49
49
  def get_driver_name(dsn: str) -> str:
50
50
  return DSN_PATTERN.findall(dsn)[0][0].lower()
51
+
52
+
53
+ def get_pool(dsn: str) -> PoolProtocol:
54
+ match get_driver_name(dsn):
55
+ case 'sqlite' | 'sqlite3':
56
+ from orm.sqlite import SQLite
57
+ return SQLite(dsn)
58
+ case 'postgres' | 'pg':
59
+ from orm.postgres import Postgres
60
+ return Postgres(dsn)
@@ -3,6 +3,7 @@ from typing import Literal, Optional
3
3
  from datetime import timedelta, datetime
4
4
  from typing import NamedTuple, Any
5
5
  from ipaddress import IPv4Address, IPv6Address, ip_address
6
+ import enum
6
7
 
7
8
 
8
9
  class Model(ABC):
@@ -94,6 +95,11 @@ class BoolField(Field): ...
94
95
  class IntegerField(Field):
95
96
  def __init__(self, *, size: Literal[2, 4, 8] = 4):
96
97
  self.size = size
98
+
99
+ def __serialize__(self, value: Any) -> int:
100
+ if isinstance(value, enum.Enum):
101
+ return value.value
102
+ return int(value)
97
103
 
98
104
 
99
105
  class DecimalField(Field): ...
@@ -104,7 +110,11 @@ class FloatField(Field):
104
110
  self.double = double
105
111
 
106
112
 
107
- class TextField(Field): ...
113
+ class TextField(Field):
114
+ def __serialize__(self, value: Any) -> str:
115
+ if isinstance(value, enum.Enum):
116
+ return value.name
117
+ return str(value)
108
118
 
109
119
 
110
120
  class TimeField(Field):
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "slinn-orm"
7
- version = "0.0.5"
7
+ version = "0.0.6"
8
8
  description = "ORM for Slinn"
9
9
  requires-python = ">=3.14"
10
10
  authors = [{ name = "Mark Radin", email = "openmiot@gmail.com" }]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: slinn-orm
3
- Version: 0.0.5
3
+ Version: 0.0.6
4
4
  Summary: ORM for Slinn
5
5
  Author-email: Mark Radin <openmiot@gmail.com>
6
6
  Requires-Python: >=3.14
File without changes
File without changes
File without changes
File without changes