reydb 1.2.1__py3-none-any.whl → 1.2.3__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.
- reydb/rbase.py +4 -4
- reydb/rbuild.py +1493 -13
- reydb/rconfig.py +27 -21
- reydb/rdb.py +2 -2
- reydb/rerror.py +29 -23
- reydb/rexec.py +20 -20
- reydb/rinfo.py +13 -13
- reydb/rorm.py +62 -24
- {reydb-1.2.1.dist-info → reydb-1.2.3.dist-info}/METADATA +1 -1
- reydb-1.2.3.dist-info/RECORD +15 -0
- reydb-1.2.1.dist-info/RECORD +0 -15
- {reydb-1.2.1.dist-info → reydb-1.2.3.dist-info}/WHEEL +0 -0
- {reydb-1.2.1.dist-info → reydb-1.2.3.dist-info}/licenses/LICENSE +0 -0
reydb/rorm.py
CHANGED
@@ -25,6 +25,7 @@ from sqlmodel import SQLModel, Session, Table
|
|
25
25
|
from sqlmodel.ext.asyncio.session import AsyncSession
|
26
26
|
from sqlmodel.main import SQLModelMetaclass, FieldInfo, default_registry
|
27
27
|
from sqlmodel.sql._expression_select_cls import SelectOfScalar as Select
|
28
|
+
from datetime import datetime, date, time, timedelta
|
28
29
|
from reykit.rbase import CallableT, Null, throw, is_instance
|
29
30
|
|
30
31
|
from . import rdb
|
@@ -274,8 +275,9 @@ class DatabaseORMModelField(DatabaseORMBase, FieldInfo):
|
|
274
275
|
kwargs['sa_type'] = kwargs.pop('field_type')
|
275
276
|
|
276
277
|
## Key auto.
|
277
|
-
if 'key_auto'
|
278
|
+
if kwargs.get('key_auto'):
|
278
279
|
kwargs['sa_column_kwargs']['autoincrement'] = True
|
280
|
+
kwargs['primary_key'] = True
|
279
281
|
else:
|
280
282
|
kwargs['sa_column_kwargs']['autoincrement'] = False
|
281
283
|
|
@@ -325,6 +327,28 @@ class DatabaseORMModel(DatabaseORMBase, SQLModel, metaclass=model_metaclass):
|
|
325
327
|
return table
|
326
328
|
|
327
329
|
|
330
|
+
@classmethod
|
331
|
+
def _name(cls_or_self, name: str) -> None:
|
332
|
+
"""
|
333
|
+
Set database table name.
|
334
|
+
"""
|
335
|
+
|
336
|
+
# Get.
|
337
|
+
table = cls_or_self._table()
|
338
|
+
table.name = name
|
339
|
+
|
340
|
+
|
341
|
+
@classmethod
|
342
|
+
def _comment(cls_or_self, comment: str) -> None:
|
343
|
+
"""
|
344
|
+
Set database table comment.
|
345
|
+
"""
|
346
|
+
|
347
|
+
# Get.
|
348
|
+
table = cls_or_self._table()
|
349
|
+
table.comment = comment
|
350
|
+
|
351
|
+
|
328
352
|
@property
|
329
353
|
def _m(self):
|
330
354
|
"""
|
@@ -419,27 +443,8 @@ class DatabaseORMModelMethod(DatabaseORMBase):
|
|
419
443
|
class DatabaseORMSuper(DatabaseORMBase, Generic[DatabaseT, DatabaseORMSessionT]):
|
420
444
|
"""
|
421
445
|
Database ORM super type.
|
422
|
-
|
423
|
-
Attributes
|
424
|
-
----------
|
425
|
-
metaData : Registry metadata instance.
|
426
|
-
DatabaseModel : Database ORM model type.
|
427
|
-
Field : Database ORM model field type.
|
428
|
-
Config : Database ORM model config type.
|
429
|
-
types : Database ORM model filed types module.
|
430
|
-
wrap_validate_model : Create decorator of validate database ORM model.
|
431
|
-
wrap_validate_filed : Create decorator of validate database ORM model field.
|
432
446
|
"""
|
433
447
|
|
434
|
-
metaData = default_registry.metadata
|
435
|
-
Model = DatabaseORMModel
|
436
|
-
Field = DatabaseORMModelField
|
437
|
-
Config = ConfigDict
|
438
|
-
types = types
|
439
|
-
types_mysql = types_mysql
|
440
|
-
wrap_validate_model = pydantic_model_validator
|
441
|
-
wrap_validate_filed = pydantic_field_validator
|
442
|
-
|
443
448
|
|
444
449
|
def __init__(self, db: DatabaseT) -> None:
|
445
450
|
"""
|
@@ -852,7 +857,7 @@ class DatabaseORMSession(
|
|
852
857
|
throw(ValueError, tables)
|
853
858
|
|
854
859
|
# Create.
|
855
|
-
|
860
|
+
metadata.create_all(self.orm.db.engine, tables, skip)
|
856
861
|
|
857
862
|
|
858
863
|
@wrap_transact
|
@@ -881,7 +886,7 @@ class DatabaseORMSession(
|
|
881
886
|
throw(ValueError, tables)
|
882
887
|
|
883
888
|
# Drop.
|
884
|
-
|
889
|
+
metadata.drop_all(self.orm.db.engine, tables, skip)
|
885
890
|
|
886
891
|
|
887
892
|
@wrap_transact
|
@@ -1219,7 +1224,7 @@ class DatabaseORMSessionAsync(
|
|
1219
1224
|
|
1220
1225
|
# Create.
|
1221
1226
|
conn = await self.sess.connection()
|
1222
|
-
await conn.run_sync(
|
1227
|
+
await conn.run_sync(metadata.create_all, tables, skip)
|
1223
1228
|
|
1224
1229
|
|
1225
1230
|
@wrap_transact
|
@@ -1249,7 +1254,7 @@ class DatabaseORMSessionAsync(
|
|
1249
1254
|
|
1250
1255
|
# Drop.
|
1251
1256
|
conn = await self.sess.connection()
|
1252
|
-
await conn.run_sync(
|
1257
|
+
await conn.run_sync(metadata.drop_all, tables, skip)
|
1253
1258
|
|
1254
1259
|
|
1255
1260
|
@wrap_transact
|
@@ -1587,3 +1592,36 @@ class DatabaseORMStatementDeleteAsync(DatabaseORMStatementAsync[None], Delete, G
|
|
1587
1592
|
"""
|
1588
1593
|
|
1589
1594
|
inherit_cache: Final = True
|
1595
|
+
|
1596
|
+
|
1597
|
+
# Simple path.
|
1598
|
+
|
1599
|
+
## Registry metadata instance.
|
1600
|
+
metadata = default_registry.metadata
|
1601
|
+
|
1602
|
+
## Database ORM model type.
|
1603
|
+
Model = DatabaseORMModel
|
1604
|
+
|
1605
|
+
## Database ORM model field type.
|
1606
|
+
Field = DatabaseORMModelField
|
1607
|
+
|
1608
|
+
## Database ORM model config type.
|
1609
|
+
Config = ConfigDict
|
1610
|
+
|
1611
|
+
## Database ORM model filed types.
|
1612
|
+
types = types
|
1613
|
+
|
1614
|
+
## Database ORM model MySQL filed types.
|
1615
|
+
types_mysql = types_mysql
|
1616
|
+
|
1617
|
+
## Create decorator of validate database ORM model.
|
1618
|
+
wrap_validate_model = pydantic_model_validator
|
1619
|
+
|
1620
|
+
## Create decorator of validate database ORM model field.
|
1621
|
+
wrap_validate_filed = pydantic_field_validator
|
1622
|
+
|
1623
|
+
## Time type.
|
1624
|
+
Datetime = datetime
|
1625
|
+
Date = date
|
1626
|
+
Time = time
|
1627
|
+
Timedelta = timedelta
|
@@ -0,0 +1,15 @@
|
|
1
|
+
reydb/__init__.py,sha256=4mnlkfJfkBfxBpCotVUJ86f4AnT8plqlFbGiH3vZ4PM,550
|
2
|
+
reydb/rall.py,sha256=IxSPGh77xz7ndDC7J8kZ_66Gq_xTAztGtnELUku1Ouw,364
|
3
|
+
reydb/rbase.py,sha256=vx37yV6LlWP89nWAfYyOf0Xm3N_e9eB8z5Mxe-aTEo4,8248
|
4
|
+
reydb/rbuild.py,sha256=8frMtmY8gKc-uYYaJPso9sm8IS3_CyTHrL_F0Wv5RI0,80554
|
5
|
+
reydb/rconfig.py,sha256=g428a0npVNgB3PMJiEpVRPwyvWm63G9KLcEru4-vPTU,19144
|
6
|
+
reydb/rconn.py,sha256=guRaR8N6RuzZzujwaeq7HhKWTizF9SrUBqEAFjfjpoo,6909
|
7
|
+
reydb/rdb.py,sha256=syyqZbEu92NbCj9O6_T6iAv7E46CyfQOC4T8qtPfHNs,14364
|
8
|
+
reydb/rerror.py,sha256=LcXyinipQw-saQxGwbkXU4BTOjb29RMX9hnAFidJN3Q,14871
|
9
|
+
reydb/rexec.py,sha256=djHx311c6mr1IjzNLqnGe-4yr3qNmYGUy4pHQA3WElQ,53042
|
10
|
+
reydb/rinfo.py,sha256=LjrqTA7JJbWJsjXwV-zKpbE1htv-whg6239hoQj4yIU,18151
|
11
|
+
reydb/rorm.py,sha256=AVV50cC5Vm8pT6gIeBUAelXd3OpdQSldPsZltL8ceOg,41375
|
12
|
+
reydb-1.2.3.dist-info/METADATA,sha256=IULuCfrYhhcnoLjLulnsgEy4R_Dzc9s5P9IrhRCVsAM,1621
|
13
|
+
reydb-1.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
14
|
+
reydb-1.2.3.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
15
|
+
reydb-1.2.3.dist-info/RECORD,,
|
reydb-1.2.1.dist-info/RECORD
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
reydb/__init__.py,sha256=4mnlkfJfkBfxBpCotVUJ86f4AnT8plqlFbGiH3vZ4PM,550
|
2
|
-
reydb/rall.py,sha256=IxSPGh77xz7ndDC7J8kZ_66Gq_xTAztGtnELUku1Ouw,364
|
3
|
-
reydb/rbase.py,sha256=0QGHxbdrcyDTY6BK7zMCTM9cRDkZyVNlL7S1j7A4Zp0,8260
|
4
|
-
reydb/rbuild.py,sha256=R_WQNpp67oHZFZlRuui_vaZAlJL4s_y5NX0gJXZY1yA,40320
|
5
|
-
reydb/rconfig.py,sha256=nZY2c6KTKWJuHXim1zEcPrIkMgqhiKb_lQQpVc-fpw8,19033
|
6
|
-
reydb/rconn.py,sha256=guRaR8N6RuzZzujwaeq7HhKWTizF9SrUBqEAFjfjpoo,6909
|
7
|
-
reydb/rdb.py,sha256=_K8_6_D7ptU8vrmPtijAeH8xCechwBXtCAusziyhxbU,14370
|
8
|
-
reydb/rerror.py,sha256=oTICXpVVtkH-u1N8pHs0f4krb1jbNU_FmcFCEHoO4yo,14852
|
9
|
-
reydb/rexec.py,sha256=XOx8JH4ApzCjXOuMplVQZQ5MCtf6UJXKGq98t-WRoFo,53102
|
10
|
-
reydb/rinfo.py,sha256=yeIZ9VmqBZtCM1Upzntal2aP7GtO0g4YsDW5LLMNOcg,18180
|
11
|
-
reydb/rorm.py,sha256=IipUvaFnS0gfHxzYkNSuM60skYsIGNBA9DvD8DnTpCc,40885
|
12
|
-
reydb-1.2.1.dist-info/METADATA,sha256=NFcX8OYkzXkDwi_NyV1uzNIqtA0kOHO-EITgjyAzJp8,1621
|
13
|
-
reydb-1.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
14
|
-
reydb-1.2.1.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
15
|
-
reydb-1.2.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|