reydb 1.2.0__py3-none-any.whl → 1.2.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.
@@ -5,7 +5,7 @@
5
5
  @Time : 2022-12-05 14:10:02
6
6
  @Author : Rey
7
7
  @Contact : reyxbo@163.com
8
- @Explain : Database parameter methods.
8
+ @Explain : Database information methods.
9
9
  """
10
10
 
11
11
 
@@ -17,29 +17,36 @@ from .rexec import Result
17
17
 
18
18
 
19
19
  __all__ = (
20
- 'DatabaseSchemaSuper',
21
- 'DatabaseSchema',
22
- 'DatabaseSchemaAsync',
23
- 'DatabaseParametersSuper',
24
- 'DatabaseParameters',
25
- 'DatabaseParametersAsync',
26
- 'DatabaseParametersVariables',
27
- 'DatabaseParametersStatus',
28
- 'DatabaseParametersVariablesGlobal',
29
- 'DatabaseParametersStatusGlobal',
30
- 'DatabaseParametersVariablesAsync',
31
- 'DatabaseParametersStatusAsync',
32
- 'DatabaseParametersVariablesGlobalAsync',
33
- 'DatabaseParametersStatusGlobalAsync'
20
+ 'DatabaseInformationBase',
21
+ 'DatabaseInformationSchemaSuper',
22
+ 'DatabaseInformationSchema',
23
+ 'DatabaseInformationSchemaAsync',
24
+ 'DatabaseInformationParameterSuper',
25
+ 'DatabaseInformationParameter',
26
+ 'DatabaseInformationParameterAsync',
27
+ 'DatabaseInformationParameterVariables',
28
+ 'DatabaseInformationParameterStatus',
29
+ 'DatabaseInformationParameterVariablesGlobal',
30
+ 'DatabaseInformationParameterStatusGlobal',
31
+ 'DatabaseInformationParameterVariablesAsync',
32
+ 'DatabaseInformationParameterStatusAsync',
33
+ 'DatabaseInformationParameterVariablesGlobalAsync',
34
+ 'DatabaseInformationParameterStatusGlobalAsync'
34
35
  )
35
36
 
36
37
 
37
38
  DatabaseT = TypeVar('DatabaseT', 'rdb.Database', 'rdb.DatabaseAsync')
38
39
 
39
40
 
40
- class DatabaseSchemaSuper(DatabaseBase, Generic[DatabaseT]):
41
+ class DatabaseInformationBase(DatabaseBase):
41
42
  """
42
- Database schema super type.
43
+ Database information base type.
44
+ """
45
+
46
+
47
+ class DatabaseInformationSchemaSuper(DatabaseInformationBase, Generic[DatabaseT]):
48
+ """
49
+ Database information schema super type.
43
50
  """
44
51
 
45
52
 
@@ -68,7 +75,7 @@ class DatabaseSchemaSuper(DatabaseBase, Generic[DatabaseT]):
68
75
  Parameter `sql` and `filter_db`.
69
76
  """
70
77
 
71
- # Handle parameter.
78
+ # Set parameter.
72
79
  filter_db = (
73
80
  'information_schema',
74
81
  'performance_schema',
@@ -186,7 +193,7 @@ class DatabaseSchemaSuper(DatabaseBase, Generic[DatabaseT]):
186
193
  Judge result.
187
194
  """
188
195
 
189
- # Handle parameter.
196
+ # Set parameter.
190
197
 
191
198
  # Judge.
192
199
  judge = (
@@ -207,9 +214,9 @@ class DatabaseSchemaSuper(DatabaseBase, Generic[DatabaseT]):
207
214
  return judge
208
215
 
209
216
 
210
- class DatabaseSchema(DatabaseSchemaSuper['rdb.Database']):
217
+ class DatabaseInformationSchema(DatabaseInformationSchemaSuper['rdb.Database']):
211
218
  """
212
- Database schema type.
219
+ Database information schema type.
213
220
  """
214
221
 
215
222
 
@@ -291,7 +298,7 @@ class DatabaseSchema(DatabaseSchemaSuper['rdb.Database']):
291
298
  Judge result.
292
299
  """
293
300
 
294
- # Handle parameter.
301
+ # Set parameter.
295
302
  if (
296
303
  refresh
297
304
  or self.db._schema is None
@@ -306,9 +313,9 @@ class DatabaseSchema(DatabaseSchemaSuper['rdb.Database']):
306
313
  return result
307
314
 
308
315
 
309
- class DatabaseSchemaAsync(DatabaseSchemaSuper['rdb.DatabaseAsync']):
316
+ class DatabaseInformationSchemaAsync(DatabaseInformationSchemaSuper['rdb.DatabaseAsync']):
310
317
  """
311
- Asynchronous database schema type.
318
+ Asynchronous database information schema type.
312
319
  """
313
320
 
314
321
 
@@ -388,7 +395,7 @@ class DatabaseSchemaAsync(DatabaseSchemaSuper['rdb.DatabaseAsync']):
388
395
  Judge result.
389
396
  """
390
397
 
391
- # Handle parameter.
398
+ # Set parameter.
392
399
  if (
393
400
  refresh
394
401
  or self.db._schema is None
@@ -403,9 +410,9 @@ class DatabaseSchemaAsync(DatabaseSchemaSuper['rdb.DatabaseAsync']):
403
410
  return result
404
411
 
405
412
 
406
- class DatabaseParametersSuper(DatabaseBase, Generic[DatabaseT]):
413
+ class DatabaseInformationParameterSuper(DatabaseInformationBase, Generic[DatabaseT]):
407
414
  """
408
- Database parameters super type.
415
+ Database information parameters super type.
409
416
  """
410
417
 
411
418
  mode: Literal['VARIABLES', 'STATUS']
@@ -428,9 +435,9 @@ class DatabaseParametersSuper(DatabaseBase, Generic[DatabaseT]):
428
435
  self.db = db
429
436
 
430
437
 
431
- class DatabaseParameters(DatabaseParametersSuper['rdb.Database']):
438
+ class DatabaseInformationParameter(DatabaseInformationParameterSuper['rdb.Database']):
432
439
  """
433
- Database parameters type.
440
+ Database information parameters type.
434
441
  """
435
442
 
436
443
 
@@ -550,9 +557,9 @@ class DatabaseParameters(DatabaseParametersSuper['rdb.Database']):
550
557
  self.db.execute(sql)
551
558
 
552
559
 
553
- class DatabaseParametersAsync(DatabaseParametersSuper['rdb.DatabaseAsync']):
560
+ class DatabaseInformationParameterAsync(DatabaseInformationParameterSuper['rdb.DatabaseAsync']):
554
561
  """
555
- Asynchrouous database parameters type.
562
+ Asynchrouous database information parameters type.
556
563
  """
557
564
 
558
565
 
@@ -676,72 +683,72 @@ class DatabaseParametersAsync(DatabaseParametersSuper['rdb.DatabaseAsync']):
676
683
  await self.db.execute(sql)
677
684
 
678
685
 
679
- class DatabaseParametersVariables(DatabaseParameters):
686
+ class DatabaseInformationParameterVariables(DatabaseInformationParameter):
680
687
  """
681
- Database variable parameters type.
688
+ Database information variable parameters type.
682
689
  """
683
690
 
684
691
  mode: Final = 'VARIABLES'
685
692
  glob: Final = False
686
693
 
687
694
 
688
- class DatabaseParametersStatus(DatabaseParameters):
695
+ class DatabaseInformationParameterStatus(DatabaseInformationParameter):
689
696
  """
690
- Database status parameters type.
697
+ Database information status parameters type.
691
698
  """
692
699
 
693
700
  mode: Final = 'STATUS'
694
701
  glob: Final = False
695
702
 
696
703
 
697
- class DatabaseParametersVariablesGlobal(DatabaseParameters):
704
+ class DatabaseInformationParameterVariablesGlobal(DatabaseInformationParameter):
698
705
  """
699
- Database global variable parameters type.
706
+ Database information global variable parameters type.
700
707
  """
701
708
 
702
709
  mode: Final = 'VARIABLES'
703
710
  glob: Final = True
704
711
 
705
712
 
706
- class DatabaseParametersStatusGlobal(DatabaseParameters):
713
+ class DatabaseInformationParameterStatusGlobal(DatabaseInformationParameter):
707
714
  """
708
- Database global status parameters type.
715
+ Database information global status parameters type.
709
716
  """
710
717
 
711
718
  mode: Final = 'STATUS'
712
719
  glob: Final = True
713
720
 
714
721
 
715
- class DatabaseParametersVariablesAsync(DatabaseParametersAsync):
722
+ class DatabaseInformationParameterVariablesAsync(DatabaseInformationParameterAsync):
716
723
  """
717
- Asynchrouous database variable parameters type.
724
+ Asynchrouous database information variable parameters type.
718
725
  """
719
726
 
720
727
  mode: Final = 'VARIABLES'
721
728
  glob: Final = False
722
729
 
723
730
 
724
- class DatabaseParametersStatusAsync(DatabaseParametersAsync):
731
+ class DatabaseInformationParameterStatusAsync(DatabaseInformationParameterAsync):
725
732
  """
726
- Asynchrouous database status parameters type.
733
+ Asynchrouous database information status parameters type.
727
734
  """
728
735
 
729
736
  mode: Final = 'STATUS'
730
737
  glob: Final = False
731
738
 
732
739
 
733
- class DatabaseParametersVariablesGlobalAsync(DatabaseParametersAsync):
740
+ class DatabaseInformationParameterVariablesGlobalAsync(DatabaseInformationParameterAsync):
734
741
  """
735
- Asynchrouous database global variable parameters type.
742
+ Asynchrouous database information global variable parameters type.
736
743
  """
737
744
 
738
745
  mode: Final = 'VARIABLES'
739
746
  glob: Final = True
740
747
 
741
748
 
742
- class DatabaseParametersStatusGlobalAsync(DatabaseParametersAsync):
749
+ class DatabaseInformationParameterStatusGlobalAsync(DatabaseInformationParameterAsync):
743
750
  """
744
- Asynchrouous database global status parameters type.
751
+ Asynchrouous database information global status parameters type.
745
752
  """
746
753
 
747
754
  mode: Final = 'STATUS'
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' in kwargs:
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
 
@@ -419,27 +421,8 @@ class DatabaseORMModelMethod(DatabaseORMBase):
419
421
  class DatabaseORMSuper(DatabaseORMBase, Generic[DatabaseT, DatabaseORMSessionT]):
420
422
  """
421
423
  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
424
  """
433
425
 
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
426
 
444
427
  def __init__(self, db: DatabaseT) -> None:
445
428
  """
@@ -852,7 +835,7 @@ class DatabaseORMSession(
852
835
  throw(ValueError, tables)
853
836
 
854
837
  # Create.
855
- self.orm.metaData.create_all(self.orm.db.engine, tables, skip)
838
+ metadata.create_all(self.orm.db.engine, tables, skip)
856
839
 
857
840
 
858
841
  @wrap_transact
@@ -881,7 +864,7 @@ class DatabaseORMSession(
881
864
  throw(ValueError, tables)
882
865
 
883
866
  # Drop.
884
- self.orm.metaData.drop_all(self.orm.db.engine, tables, skip)
867
+ metadata.drop_all(self.orm.db.engine, tables, skip)
885
868
 
886
869
 
887
870
  @wrap_transact
@@ -1219,7 +1202,7 @@ class DatabaseORMSessionAsync(
1219
1202
 
1220
1203
  # Create.
1221
1204
  conn = await self.sess.connection()
1222
- await conn.run_sync(self.orm.metaData.create_all, tables, skip)
1205
+ await conn.run_sync(metadata.create_all, tables, skip)
1223
1206
 
1224
1207
 
1225
1208
  @wrap_transact
@@ -1249,7 +1232,7 @@ class DatabaseORMSessionAsync(
1249
1232
 
1250
1233
  # Drop.
1251
1234
  conn = await self.sess.connection()
1252
- await conn.run_sync(self.orm.metaData.drop_all, tables, skip)
1235
+ await conn.run_sync(metadata.drop_all, tables, skip)
1253
1236
 
1254
1237
 
1255
1238
  @wrap_transact
@@ -1587,3 +1570,36 @@ class DatabaseORMStatementDeleteAsync(DatabaseORMStatementAsync[None], Delete, G
1587
1570
  """
1588
1571
 
1589
1572
  inherit_cache: Final = True
1573
+
1574
+
1575
+ # Simple path.
1576
+
1577
+ ## Registry metadata instance.
1578
+ metadata = default_registry.metadata
1579
+
1580
+ ## Database ORM model type.
1581
+ Model = DatabaseORMModel
1582
+
1583
+ ## Database ORM model field type.
1584
+ Field = DatabaseORMModelField
1585
+
1586
+ ## Database ORM model config type.
1587
+ Config = ConfigDict
1588
+
1589
+ ## Database ORM model filed types.
1590
+ types = types
1591
+
1592
+ ## Database ORM model MySQL filed types.
1593
+ types_mysql = types_mysql
1594
+
1595
+ ## Create decorator of validate database ORM model.
1596
+ wrap_validate_model = pydantic_model_validator
1597
+
1598
+ ## Create decorator of validate database ORM model field.
1599
+ wrap_validate_filed = pydantic_field_validator
1600
+
1601
+ ## Time type.
1602
+ Datetime = datetime
1603
+ Date = date
1604
+ Time = time
1605
+ Timedelta = timedelta
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reydb
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: Database method set.
5
5
  Project-URL: homepage, https://github.com/reyxbo/reydb/
6
6
  Author-email: Rey <reyxbo@163.com>
@@ -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=rmwfkjxjhavcbyn-V0ZTqwKNq3wKmgvHng8p5I0dghQ,40281
5
+ reydb/rconfig.py,sha256=5ZfFQwgt6JI5k1luv7PIj3H9Izuc6KNMOCFCJGBb1rQ,18998
6
+ reydb/rconn.py,sha256=guRaR8N6RuzZzujwaeq7HhKWTizF9SrUBqEAFjfjpoo,6909
7
+ reydb/rdb.py,sha256=syyqZbEu92NbCj9O6_T6iAv7E46CyfQOC4T8qtPfHNs,14364
8
+ reydb/rerror.py,sha256=renVDvi5e6-AC-y2KPksARPRX978WFh0Hqa9yfl9j1A,14735
9
+ reydb/rexec.py,sha256=djHx311c6mr1IjzNLqnGe-4yr3qNmYGUy4pHQA3WElQ,53042
10
+ reydb/rinfo.py,sha256=9qpVFqFwMol5_n9gE3zYLv9Fn5r2EuVD5ibgQkSXYyw,18168
11
+ reydb/rorm.py,sha256=X99AKlpMQk3et9_3x1ddpKn1BxZRULLG8x_opYbWVX8,40934
12
+ reydb-1.2.2.dist-info/METADATA,sha256=J_Jq9TRbL2LRW154knFoOtwv8wWVQQqhfup0YTfEwRM,1621
13
+ reydb-1.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
+ reydb-1.2.2.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
15
+ reydb-1.2.2.dist-info/RECORD,,
@@ -1,15 +0,0 @@
1
- reydb/__init__.py,sha256=G2U0uiNjk2koYxIZjf9zvHoiQFO485XMnfQBMYSUdRc,549
2
- reydb/rall.py,sha256=sOeiVXSIo2voFiiZaRx8h7_wWrx8fFjXkRQRSYHQccA,365
3
- reydb/rbase.py,sha256=0QGHxbdrcyDTY6BK7zMCTM9cRDkZyVNlL7S1j7A4Zp0,8260
4
- reydb/rbuild.py,sha256=R_WQNpp67oHZFZlRuui_vaZAlJL4s_y5NX0gJXZY1yA,40320
5
- reydb/rconfig.py,sha256=mVRrkWa35stM5_sB0rD7VtgqLkVDv0BDnV_u2AGh0kI,18962
6
- reydb/rconn.py,sha256=guRaR8N6RuzZzujwaeq7HhKWTizF9SrUBqEAFjfjpoo,6909
7
- reydb/rdb.py,sha256=QB9het4tAPnJo4urWJ4oePI1g1avNI8O1P0-VPJLDEo,13809
8
- reydb/rerror.py,sha256=LlEmKREe88QKLU3xf4mF88nXnGSQodrUruQAm9ifUeQ,14781
9
- reydb/rexec.py,sha256=NLSvwwFhf60OndW3pjffzyMbWcLykhTbBbfI1YSueQ8,53223
10
- reydb/rorm.py,sha256=IipUvaFnS0gfHxzYkNSuM60skYsIGNBA9DvD8DnTpCc,40885
11
- reydb/rparam.py,sha256=S32dAKrCM0c4Qm-fhZkIRRhshsK1MmI12NgavNBfvJg,17443
12
- reydb-1.2.0.dist-info/METADATA,sha256=0wocK72W-r7ZRvnaiZ4JFfJ9RLVCkXs2u6yrx1foDFw,1621
13
- reydb-1.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
- reydb-1.2.0.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
15
- reydb-1.2.0.dist-info/RECORD,,
File without changes