esuls 0.1.1__py3-none-any.whl → 0.1.2__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.
- esuls/db_cli.py +9 -10
- {esuls-0.1.1.dist-info → esuls-0.1.2.dist-info}/METADATA +1 -1
- esuls-0.1.2.dist-info/RECORD +9 -0
- esuls-0.1.1.dist-info/RECORD +0 -9
- {esuls-0.1.1.dist-info → esuls-0.1.2.dist-info}/WHEEL +0 -0
- {esuls-0.1.1.dist-info → esuls-0.1.2.dist-info}/licenses/LICENSE +0 -0
- {esuls-0.1.1.dist-info → esuls-0.1.2.dist-info}/top_level.txt +0 -0
esuls/db_cli.py
CHANGED
|
@@ -9,6 +9,7 @@ from functools import lru_cache
|
|
|
9
9
|
import uuid
|
|
10
10
|
import contextlib
|
|
11
11
|
import enum
|
|
12
|
+
from loguru import logger
|
|
12
13
|
|
|
13
14
|
T = TypeVar('T')
|
|
14
15
|
SchemaType = TypeVar('SchemaType', bound='BaseModel')
|
|
@@ -64,7 +65,7 @@ class AsyncDB(Generic[SchemaType]):
|
|
|
64
65
|
|
|
65
66
|
async def _init_schema(self, db: aiosqlite.Connection) -> None:
|
|
66
67
|
"""Generate schema from dataclass structure with support for field additions."""
|
|
67
|
-
|
|
68
|
+
logger.debug(f"Initializing schema for {self.schema_class.__name__} in table {self.table_name}")
|
|
68
69
|
|
|
69
70
|
field_defs = []
|
|
70
71
|
indexes = []
|
|
@@ -85,12 +86,12 @@ class AsyncDB(Generic[SchemaType]):
|
|
|
85
86
|
|
|
86
87
|
# Process all fields in the dataclass - ONLY THIS SCHEMA CLASS
|
|
87
88
|
schema_fields = fields(self.schema_class)
|
|
88
|
-
|
|
89
|
+
logger.debug(f"Processing {len(schema_fields)} fields for {self.schema_class.__name__}")
|
|
89
90
|
|
|
90
91
|
for f in schema_fields:
|
|
91
92
|
field_name = f.name
|
|
92
93
|
field_type = self._type_hints.get(field_name)
|
|
93
|
-
|
|
94
|
+
logger.debug(f" Field: {field_name} -> {field_type}")
|
|
94
95
|
|
|
95
96
|
# Map Python types to SQLite types
|
|
96
97
|
if field_type in (int, bool):
|
|
@@ -123,7 +124,7 @@ class AsyncDB(Generic[SchemaType]):
|
|
|
123
124
|
elif field_name not in existing_columns:
|
|
124
125
|
# Alter table to add the new column without NOT NULL constraint
|
|
125
126
|
alter_sql = f"ALTER TABLE {self.table_name} ADD COLUMN {field_name} {sql_type}"
|
|
126
|
-
|
|
127
|
+
logger.debug(f" Adding new column: {alter_sql}")
|
|
127
128
|
await db.execute(alter_sql)
|
|
128
129
|
await db.commit()
|
|
129
130
|
|
|
@@ -147,7 +148,7 @@ class AsyncDB(Generic[SchemaType]):
|
|
|
147
148
|
{', '.join(field_defs)}{constraints_sql}
|
|
148
149
|
)
|
|
149
150
|
"""
|
|
150
|
-
|
|
151
|
+
logger.debug(f"Creating table: {create_sql}")
|
|
151
152
|
await db.execute(create_sql)
|
|
152
153
|
|
|
153
154
|
# Create indexes
|
|
@@ -155,7 +156,7 @@ class AsyncDB(Generic[SchemaType]):
|
|
|
155
156
|
await db.execute(idx_stmt)
|
|
156
157
|
|
|
157
158
|
await db.commit()
|
|
158
|
-
|
|
159
|
+
logger.debug(f"Schema initialization complete for {self.schema_class.__name__}")
|
|
159
160
|
|
|
160
161
|
@contextlib.asynccontextmanager
|
|
161
162
|
async def transaction(self):
|
|
@@ -279,8 +280,7 @@ class AsyncDB(Generic[SchemaType]):
|
|
|
279
280
|
|
|
280
281
|
except Exception as e:
|
|
281
282
|
if skip_errors:
|
|
282
|
-
|
|
283
|
-
# print(f"Save error (skipped): {e}")
|
|
283
|
+
logger.warning(f"Save error (skipped): {e}")
|
|
284
284
|
continue
|
|
285
285
|
raise
|
|
286
286
|
|
|
@@ -327,8 +327,7 @@ class AsyncDB(Generic[SchemaType]):
|
|
|
327
327
|
|
|
328
328
|
except Exception as e:
|
|
329
329
|
if skip_errors:
|
|
330
|
-
|
|
331
|
-
# print(f"Save error (skipped): {e}")
|
|
330
|
+
logger.warning(f"Save error (skipped): {e}")
|
|
332
331
|
return False
|
|
333
332
|
raise
|
|
334
333
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
esuls/__init__.py,sha256=z77yDz8qY_y0dTvy76Sg8_oyNSLSBE8zE1d49EBUb30,467
|
|
2
|
+
esuls/db_cli.py,sha256=9mxN4sl6QYNZwWDLqeaaMM4dSlWwHXZhfk5jLtQfq04,17380
|
|
3
|
+
esuls/request_cli.py,sha256=8wt2MQ4Y3J-vEVacizbbuHLSrENm41UhnnGGzi-DfDE,14277
|
|
4
|
+
esuls/utils.py,sha256=R0peIanodvDrKYFWWdLZ9weIPAUZX787XIjZH40qNo0,677
|
|
5
|
+
esuls-0.1.2.dist-info/licenses/LICENSE,sha256=AY0N01ARt0kbKB7CkByYLqqNQU-yalb-rpv-eXITEWA,1066
|
|
6
|
+
esuls-0.1.2.dist-info/METADATA,sha256=plbpOdnHoG60yFdu5pE_h-WqLTgGcuEhlX7LBUafbng,6928
|
|
7
|
+
esuls-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
+
esuls-0.1.2.dist-info/top_level.txt,sha256=WWBDHRhQ0DQLBZKD7Un8uFN93GvVQnP4WvJKkvbACVA,6
|
|
9
|
+
esuls-0.1.2.dist-info/RECORD,,
|
esuls-0.1.1.dist-info/RECORD
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
esuls/__init__.py,sha256=z77yDz8qY_y0dTvy76Sg8_oyNSLSBE8zE1d49EBUb30,467
|
|
2
|
-
esuls/db_cli.py,sha256=YOPBlKpLV4GG5WzcHov6hpZkmW-vaL1BNlBcAm8bz4k,17424
|
|
3
|
-
esuls/request_cli.py,sha256=8wt2MQ4Y3J-vEVacizbbuHLSrENm41UhnnGGzi-DfDE,14277
|
|
4
|
-
esuls/utils.py,sha256=R0peIanodvDrKYFWWdLZ9weIPAUZX787XIjZH40qNo0,677
|
|
5
|
-
esuls-0.1.1.dist-info/licenses/LICENSE,sha256=AY0N01ARt0kbKB7CkByYLqqNQU-yalb-rpv-eXITEWA,1066
|
|
6
|
-
esuls-0.1.1.dist-info/METADATA,sha256=tDJJpenllntwVCcVvKp_aCFFnEyvOSbRt2G1aP4Vcak,6928
|
|
7
|
-
esuls-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
-
esuls-0.1.1.dist-info/top_level.txt,sha256=WWBDHRhQ0DQLBZKD7Un8uFN93GvVQnP4WvJKkvbACVA,6
|
|
9
|
-
esuls-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|