dapper-sqls 1.2.0__py3-none-any.whl → 1.2.1__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.
- dapper_sqls/builders/model/model.py +47 -47
- {dapper_sqls-1.2.0.dist-info → dapper_sqls-1.2.1.dist-info}/METADATA +1 -1
- {dapper_sqls-1.2.0.dist-info → dapper_sqls-1.2.1.dist-info}/RECORD +5 -5
- {dapper_sqls-1.2.0.dist-info → dapper_sqls-1.2.1.dist-info}/WHEEL +0 -0
- {dapper_sqls-1.2.0.dist-info → dapper_sqls-1.2.1.dist-info}/top_level.txt +0 -0
@@ -373,42 +373,46 @@ class ModelBuilder(object):
|
|
373
373
|
return grouped_list
|
374
374
|
|
375
375
|
def get_models_db(self, tables : dict[str, SqlTable]):
|
376
|
+
models : list[TableBaseModel] = []
|
377
|
+
for table in tables.values():
|
378
|
+
if not table.available:
|
379
|
+
continue
|
380
|
+
models.append(self.get_model_db(table))
|
381
|
+
return models
|
376
382
|
|
383
|
+
def get_model_db(self, table : SqlTable):
|
384
|
+
|
377
385
|
from datetime import datetime
|
378
386
|
from pydantic import Field
|
379
387
|
from typing import Union, Optional, ClassVar, Set
|
380
388
|
from dapper_sqls import (TableBaseModel, StringQueryField, NumericQueryField, BoolQueryField, DateQueryField, BytesQueryField,
|
381
|
-
|
382
|
-
|
383
|
-
models : list[TableBaseModel] = []
|
384
|
-
for table in tables.values():
|
385
|
-
if not table.available:
|
386
|
-
continue
|
389
|
+
JoinNumericCondition, JoinStringCondition, JoinBooleanCondition, JoinDateCondition, JoinBytesCondition)
|
387
390
|
|
388
|
-
|
391
|
+
|
392
|
+
table_description = create_table_description(table)
|
389
393
|
|
390
|
-
|
391
|
-
|
392
|
-
|
394
|
+
table_name = table.TABLE_NAME
|
395
|
+
class_name = table_name
|
396
|
+
schema = table.TABLE_SCHEMA
|
393
397
|
|
394
|
-
|
395
|
-
|
398
|
+
fields = [create_field(row) for row in table.COLUMNS if row.available]
|
399
|
+
fields_str = "\n ".join(fields)
|
396
400
|
|
397
|
-
|
401
|
+
identities = {d.COLUMN_NAME for d in table.COLUMNS if d.IS_IDENTITY == "YES" and d.available}
|
398
402
|
|
399
|
-
|
403
|
+
primary_keys = {d.COLUMN_NAME for d in table.COLUMNS if d.IS_PRIMARY_KEY == "YES" and d.available}
|
400
404
|
|
401
|
-
|
405
|
+
optional_fields = {d.COLUMN_NAME for d in table.COLUMNS if d.IS_NULLABLE == "YES" and d.available}
|
402
406
|
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
407
|
+
max_length_fields = {
|
408
|
+
d.COLUMN_NAME: d.CHARACTER_MAXIMUM_LENGTH
|
409
|
+
for d in table.COLUMNS
|
410
|
+
if d.CHARACTER_MAXIMUM_LENGTH is not None and d.CHARACTER_MAXIMUM_LENGTH > 0 and d.available
|
411
|
+
}
|
408
412
|
|
409
|
-
|
413
|
+
table_alias = f'_alias_{table_name.lower()}_alias_'
|
410
414
|
|
411
|
-
|
415
|
+
content_model = f'''# coding: utf-8
|
412
416
|
class {class_name}(TableBaseModel):
|
413
417
|
TABLE_NAME: ClassVar[str] = '[{schema}].[{table_name}]'
|
414
418
|
|
@@ -426,31 +430,27 @@ class {class_name}(TableBaseModel):
|
|
426
430
|
|
427
431
|
{fields_str}
|
428
432
|
'''
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
models.append(model_class)
|
451
|
-
|
452
|
-
return models
|
453
|
-
|
433
|
+
local_vars = {}
|
434
|
+
exec(content_model, {
|
435
|
+
"TableBaseModel": TableBaseModel,
|
436
|
+
"StringQueryField": StringQueryField,
|
437
|
+
"NumericQueryField": NumericQueryField,
|
438
|
+
"BoolQueryField": BoolQueryField,
|
439
|
+
"DateQueryField": DateQueryField,
|
440
|
+
"BytesQueryField": BytesQueryField,
|
441
|
+
"JoinNumericCondition": JoinNumericCondition,
|
442
|
+
"JoinStringCondition": JoinStringCondition,
|
443
|
+
"JoinBooleanCondition": JoinBooleanCondition,
|
444
|
+
"JoinDateCondition": JoinDateCondition,
|
445
|
+
"JoinBytesCondition": JoinBytesCondition,
|
446
|
+
"datetime": datetime,
|
447
|
+
"Field": Field,
|
448
|
+
"Union": Union,
|
449
|
+
"Optional": Optional,
|
450
|
+
"ClassVar": ClassVar,
|
451
|
+
"Set": Set
|
452
|
+
}, local_vars)
|
453
|
+
return local_vars[class_name]
|
454
454
|
|
455
455
|
def create_model_db(self, dir_path : str, create_orm = True, create_stp = True, *, table_catalog : str | list[str] | tuple[str] = "all",
|
456
456
|
table_schema : str | list[str] | tuple[str] = "all",
|
@@ -11,7 +11,7 @@ dapper_sqls/builders/query.py,sha256=Qf2V4MSSrZsHsMoSjczrAga5gcRf6Vl-vhJxtcLGVBA
|
|
11
11
|
dapper_sqls/builders/stored.py,sha256=EHNRTLFYDVvqqWkmQggzJIbXfTKZN4Se8rbME7wLPHU,3131
|
12
12
|
dapper_sqls/builders/stp.py,sha256=LELylyG5tefcIk6kpsUTTuCkakRKTu93OwWCHB6mxU4,4915
|
13
13
|
dapper_sqls/builders/model/__init__.py,sha256=9cAgoo-zu82YhtsmePseZhfeX94UMwfYuP9j-3d597Q,41
|
14
|
-
dapper_sqls/builders/model/model.py,sha256=
|
14
|
+
dapper_sqls/builders/model/model.py,sha256=OULDuudqkj5oh1NlYzDJZwbQVDXh735LXhyCWiqpvWM,34668
|
15
15
|
dapper_sqls/builders/model/utils.py,sha256=w-EBGxwltFFIw4jGvuQAvyCAnoDysqaPhfk86JLvCTs,27583
|
16
16
|
dapper_sqls/dapper/__init__.py,sha256=AlQJ-QYMqKeerSQBM8Dc9_VQwUKCN4bl4ThKHsTlYms,38
|
17
17
|
dapper_sqls/dapper/dapper.py,sha256=3sFRtgw_M3zZI8dyDJacVFwzAuH7jbyQehfCiYMymZs,2584
|
@@ -34,7 +34,7 @@ dapper_sqls/sqlite/installer.py,sha256=nCDGRNUEvAEHx8Pw3izXx9miJJ3o5cjjPWA07nlqA
|
|
34
34
|
dapper_sqls/sqlite/local_database.py,sha256=kuEVRJvzUUQg3X1Abq9ZYslO9n5IMovaCj7jnB51qSs,5902
|
35
35
|
dapper_sqls/sqlite/models.py,sha256=m1I0-iYDdv-4fVYMsAboRYHbMEcwI4GScZSdbs7_nUY,2232
|
36
36
|
dapper_sqls/sqlite/utils.py,sha256=22n2ry7_7b7XGDjwv3sY8swADpXDAynR0-E8WQrvHzc,230
|
37
|
-
dapper_sqls-1.2.
|
38
|
-
dapper_sqls-1.2.
|
39
|
-
dapper_sqls-1.2.
|
40
|
-
dapper_sqls-1.2.
|
37
|
+
dapper_sqls-1.2.1.dist-info/METADATA,sha256=Lcvmw9RHD9l5YFo7Lag1BaqHIdKwduFjcHlUWefuqHk,964
|
38
|
+
dapper_sqls-1.2.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
39
|
+
dapper_sqls-1.2.1.dist-info/top_level.txt,sha256=Pe1YqCPngnYbSVdhJyDrdFWHFCOqBvFW8WK7kTaIax4,12
|
40
|
+
dapper_sqls-1.2.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|