reydb 1.2.1__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.
reydb/rbase.py CHANGED
@@ -75,7 +75,7 @@ def handle_sql(sql: str | TextClause) -> TextClause:
75
75
  TextClause instance.
76
76
  """
77
77
 
78
- # Handle parameter.
78
+ # Set parameter.
79
79
  if type(sql) == TextClause:
80
80
  sql = sql.text
81
81
 
@@ -102,7 +102,7 @@ def handle_data(data: list[dict], sql: str | TextClause) -> list[dict]:
102
102
  Filled data.
103
103
  """
104
104
 
105
- # Handle parameter.
105
+ # Set parameter.
106
106
  if type(sql) == TextClause:
107
107
  sql = sql.text
108
108
 
@@ -298,7 +298,7 @@ def get_syntax(self, sql: str | TextClause) -> list[str]:
298
298
  SQL syntax type for each segment.
299
299
  """
300
300
 
301
- # Handle parameter.
301
+ # Set parameter.
302
302
  if type(sql) == TextClause:
303
303
  sql = sql.text
304
304
 
@@ -325,7 +325,7 @@ def is_multi_sql(self, sql: str | TextClause) -> bool:
325
325
  Judgment result.
326
326
  """
327
327
 
328
- # Handle parameter.
328
+ # Set parameter.
329
329
  if type(sql) == TextClause:
330
330
  sql = sql.text
331
331
 
reydb/rbuild.py CHANGED
@@ -121,7 +121,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
121
121
  Field set SQL.
122
122
  """
123
123
 
124
- # Handle parameter.
124
+ # Set parameter.
125
125
 
126
126
  ## Constraint.
127
127
  constraint = ' ' + constraint
@@ -175,7 +175,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
175
175
  Index set SQL.
176
176
  """
177
177
 
178
- # Handle parameter.
178
+ # Set parameter.
179
179
  if fields.__class__ == str:
180
180
  fields = [fields]
181
181
  match type_:
@@ -275,7 +275,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
275
275
  SQL.
276
276
  """
277
277
 
278
- # Handle parameter.
278
+ # Set parameter.
279
279
  if type(path) == str:
280
280
  database, table = self.db.database, path
281
281
  else:
@@ -363,7 +363,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
363
363
  SQL.
364
364
  """
365
365
 
366
- # Handle parameter.
366
+ # Set parameter.
367
367
  if type(path) == str:
368
368
  database, table = self.db.database, path
369
369
  else:
@@ -478,7 +478,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
478
478
  SQL.
479
479
  """
480
480
 
481
- # Handle parameter.
481
+ # Set parameter.
482
482
  if type(path) == str:
483
483
  database, table = self.db.database, path
484
484
  else:
@@ -509,7 +509,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
509
509
  SQL.
510
510
  """
511
511
 
512
- # Handle parameter.
512
+ # Set parameter.
513
513
  if type(path) == str:
514
514
  database, table = self.db.database, path
515
515
  else:
@@ -616,7 +616,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
616
616
  SQL.
617
617
  """
618
618
 
619
- # Handle parameter.
619
+ # Set parameter.
620
620
  if type(path) == str:
621
621
  database, table = self.db.database, path
622
622
  else:
@@ -704,7 +704,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
704
704
  SQL.
705
705
  """
706
706
 
707
- # Handle parameter.
707
+ # Set parameter.
708
708
  if type(path) == str:
709
709
  database, table = self.db.database, path
710
710
  else:
@@ -792,7 +792,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
792
792
  SQL.
793
793
  """
794
794
 
795
- # Handle parameter.
795
+ # Set parameter.
796
796
  if type(path) == str:
797
797
  database, table = self.db.database, path
798
798
  else:
@@ -886,7 +886,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
886
886
  SQL.
887
887
  """
888
888
 
889
- # Handle parameter.
889
+ # Set parameter.
890
890
  if type(path) == str:
891
891
  database, table = self.db.database, path
892
892
  else:
@@ -917,7 +917,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
917
917
  SQL.
918
918
  """
919
919
 
920
- # Handle parameter.
920
+ # Set parameter.
921
921
  if type(path) == str:
922
922
  database, table = self.db.database, path
923
923
  else:
@@ -1104,7 +1104,7 @@ class DatabaseBuild(DatabaseBuildSuper['rdb.Database']):
1104
1104
  skip : Whether skip existing table.
1105
1105
  """
1106
1106
 
1107
- # Handle parameter.
1107
+ # Set parameter.
1108
1108
  databases = databases or []
1109
1109
  tables = tables or []
1110
1110
  views = views or []
@@ -1324,7 +1324,7 @@ class DatabaseBuildAsync(DatabaseBuildSuper['rdb.DatabaseAsync']):
1324
1324
  skip : Whether skip existing table.
1325
1325
  """
1326
1326
 
1327
- # Handle parameter.
1327
+ # Set parameter.
1328
1328
  databases = databases or []
1329
1329
  tables = tables or []
1330
1330
  tables_orm = tables_orm or []
reydb/rconfig.py CHANGED
@@ -19,8 +19,8 @@ from datetime import (
19
19
  from reykit.rbase import Null, throw
20
20
 
21
21
  from . import rdb
22
+ from . import rorm
22
23
  from .rbase import DatabaseBase
23
- from .rorm import DatabaseORM as orm
24
24
 
25
25
 
26
26
  __all__ = (
@@ -71,19 +71,18 @@ class DatabaseConfigSuper(DatabaseBase, Generic[DatabaseT]):
71
71
  Handle method of check and build database tables, by `self.db_names`.
72
72
  """
73
73
 
74
- # Handle parameter.
74
+ # Set parameter.
75
75
 
76
76
  ## Table.
77
- class Config(orm.Model, table=True):
77
+ class Config(rorm.Model, table=True):
78
78
  __name__ = self.db_names['config']
79
79
  __comment__ = 'Config data table.'
80
- create_time: Datetime = orm.Field(field_default='CURRENT_TIMESTAMP', not_null=True, index_n=True, comment='Config create time.')
81
- update_time: Datetime = orm.Field(field_default='CURRENT_TIMESTAMP', index_n=True, comment='Config update time.')
82
- key: str = orm.Field(field_type=orm.types.VARCHAR(50), key=True, not_null=True, comment='Config key.')
83
- value: str = orm.Field(field_type=orm.types.TEXT, not_null=True, comment='Config value.')
84
- type: str = orm.Field(field_type=orm.types.VARCHAR(50), not_null=True, comment='Config value type.')
85
- note: str = orm.Field(field_type=orm.types.VARCHAR(500), comment='Config note.')
86
-
80
+ create_time: rorm.Datetime = rorm.Field(field_default='CURRENT_TIMESTAMP', not_null=True, index_n=True, comment='Config create time.')
81
+ update_time: rorm.Datetime = rorm.Field(field_default='CURRENT_TIMESTAMP', index_n=True, comment='Config update time.')
82
+ key: str = rorm.Field(field_type=rorm.types.VARCHAR(50), key=True, comment='Config key.')
83
+ value: str = rorm.Field(field_type=rorm.types.TEXT, not_null=True, comment='Config value.')
84
+ type: str = rorm.Field(field_type=rorm.types.VARCHAR(50), not_null=True, comment='Config value type.')
85
+ note: str = rorm.Field(field_type=rorm.types.VARCHAR(500), comment='Config note.')
87
86
  tables = [Config]
88
87
 
89
88
  ## View stats.
@@ -142,7 +141,7 @@ class DatabaseConfig(DatabaseConfigSuper['rdb.Database']):
142
141
  Check and build database tables, by `self.db_names`.
143
142
  """
144
143
 
145
- # Handle parameter.
144
+ # Set parameter.
146
145
  tables, views_stats = self.handle_build_db()
147
146
 
148
147
  # Build.
@@ -265,7 +264,7 @@ class DatabaseConfig(DatabaseConfigSuper['rdb.Database']):
265
264
  - `ConfigTable`: Config key and value and note.
266
265
  """
267
266
 
268
- # Handle parameter.
267
+ # Set parameter.
269
268
  if type(data) == dict:
270
269
  data = [
271
270
  {
@@ -426,7 +425,7 @@ class DatabaseConfig(DatabaseConfigSuper['rdb.Database']):
426
425
  value : Config value.
427
426
  """
428
427
 
429
- # Handle parameter.
428
+ # Set parameter.
430
429
  if type(key_note) != str:
431
430
  key, note = key_note
432
431
  else:
@@ -467,7 +466,7 @@ class DatabaseConfigAsync(DatabaseConfigSuper['rdb.DatabaseAsync']):
467
466
  Asynchronous check and build database tables, by `self.db_names`.
468
467
  """
469
468
 
470
- # Handle parameter.
469
+ # Set parameter.
471
470
  tables, views_stats = self.handle_build_db()
472
471
 
473
472
  # Build.
@@ -590,7 +589,7 @@ class DatabaseConfigAsync(DatabaseConfigSuper['rdb.DatabaseAsync']):
590
589
  - `ConfigTable`: Config key and value and note.
591
590
  """
592
591
 
593
- # Handle parameter.
592
+ # Set parameter.
594
593
  if type(data) == dict:
595
594
  data = [
596
595
  {
@@ -751,7 +750,7 @@ class DatabaseConfigAsync(DatabaseConfigSuper['rdb.DatabaseAsync']):
751
750
  value : Config value.
752
751
  """
753
752
 
754
- # Handle parameter.
753
+ # Set parameter.
755
754
  if type(key_note) != str:
756
755
  key, note = key_note
757
756
  else:
reydb/rdb.py CHANGED
@@ -113,7 +113,7 @@ class DatabaseSuper(
113
113
  query : Remote server database parameters.
114
114
  """
115
115
 
116
- # Handle parameter.
116
+ # Set parameter.
117
117
  if type(port) == str:
118
118
  port = int(port)
119
119
 
@@ -237,7 +237,7 @@ class DatabaseSuper(
237
237
  Engine object.
238
238
  """
239
239
 
240
- # Handle parameter.
240
+ # Set parameter.
241
241
  engine_params = {
242
242
  'url': self.url,
243
243
  'pool_size': self.pool_size,
reydb/rerror.py CHANGED
@@ -14,12 +14,11 @@ from collections.abc import Callable
14
14
  from inspect import iscoroutinefunction
15
15
  from traceback import StackSummary
16
16
  from functools import wraps as functools_wraps
17
- from datetime import datetime as Datetime
18
17
  from reykit.rbase import T, Exit, catch_exc
19
18
 
20
19
  from . import rdb
20
+ from . import rorm
21
21
  from .rbase import DatabaseBase
22
- from .rorm import DatabaseORM as orm
23
22
 
24
23
 
25
24
  __all__ = (
@@ -66,18 +65,18 @@ class DatabaseErrorSuper(DatabaseBase, Generic[DatabaseT]):
66
65
  Handle method of check and build database tables, by `self.db_names`.
67
66
  """
68
67
 
69
- # Handle parameter.
68
+ # Set parameter.
70
69
 
71
70
  ## Table.
72
- class error(orm.Model, table=True):
71
+ class error(rorm.Model, table=True):
73
72
  __name__ = self.db_names['error']
74
73
  __comment__ = 'Error log table.'
75
- create_time: Datetime = orm.Field(field_default='CURRENT_TIMESTAMP', not_null=True, index_n=True, comment='Record create time.')
76
- id: int = orm.Field(field_name='idd', field_type=orm.types_mysql.INTEGER(unsigned=True), key=True, key_auto=True, not_null=True, comment='ID.')
77
- type: str = orm.Field(field_type=orm.types.VARCHAR(50), not_null=True, index_n=True, comment='Error type.')
78
- data: str = orm.Field(field_type=orm.types.JSON, comment='Error data.')
79
- stack: str = orm.Field(field_type=orm.types.JSON, comment='Error code traceback stack.')
80
- note: str = orm.Field(field_type=orm.types.VARCHAR(500), comment='Error note.')
74
+ create_time: rorm.Datetime = rorm.Field(field_default='CURRENT_TIMESTAMP', not_null=True, index_n=True, comment='Record create time.')
75
+ id: int = rorm.Field(field_type=rorm.types_mysql.INTEGER(unsigned=True), key_auto=True, comment='ID.')
76
+ type: str = rorm.Field(field_type=rorm.types.VARCHAR(50), not_null=True, index_n=True, comment='Error type.')
77
+ data: str = rorm.Field(field_type=rorm.types.JSON, comment='Error data.')
78
+ stack: str = rorm.Field(field_type=rorm.types.JSON, comment='Error code traceback stack.')
79
+ note: str = rorm.Field(field_type=rorm.types.VARCHAR(500), comment='Error note.')
81
80
  tables = [error]
82
81
 
83
82
  ## View stats.
@@ -151,7 +150,7 @@ class DatabaseErrorSuper(DatabaseBase, Generic[DatabaseT]):
151
150
  note : Exception note.
152
151
  """
153
152
 
154
- # Handle parameter.
153
+ # Set parameter.
155
154
  exc_type = type(exc).__name__
156
155
  exc_data = list(exc.args) or None
157
156
  exc_stack = [
@@ -185,7 +184,7 @@ class DatabaseError(DatabaseErrorSuper['rdb.Database']):
185
184
  Check and build database tables, by `self.db_names`.
186
185
  """
187
186
 
188
- # Handle parameter.
187
+ # Set parameter.
189
188
  tables, views_stats = self.handle_build_db()
190
189
 
191
190
  # Build.
@@ -208,7 +207,7 @@ class DatabaseError(DatabaseErrorSuper['rdb.Database']):
208
207
  note : Exception note.
209
208
  """
210
209
 
211
- # Handle parameter.
210
+ # Set parameter.
212
211
  data = self.handle_record(exc, stack, note)
213
212
 
214
213
  # Insert.
@@ -235,7 +234,7 @@ class DatabaseError(DatabaseErrorSuper['rdb.Database']):
235
234
  filter_type : Exception types of not insert, but still throw exception.
236
235
  """
237
236
 
238
- # Handle parameter.
237
+ # Set parameter.
239
238
  _, exc, stack = catch_exc()
240
239
 
241
240
  # Filter.
@@ -293,7 +292,7 @@ class DatabaseError(DatabaseErrorSuper['rdb.Database']):
293
292
  >>> func(*args, **kwargs)
294
293
  """
295
294
 
296
- # Handle parameter.
295
+ # Set parameter.
297
296
  if issubclass(filter_type, BaseException):
298
297
  filter_type = (filter_type,)
299
298
 
@@ -363,7 +362,7 @@ class DatabaseErrorAsync(DatabaseErrorSuper['rdb.DatabaseAsync']):
363
362
  Asynchrouous check and build database tables, by `self.db_names`.
364
363
  """
365
364
 
366
- # Handle parameter.
365
+ # Set parameter.
367
366
  tables, views_stats = self.handle_build_db()
368
367
 
369
368
  # Build.
@@ -386,7 +385,7 @@ class DatabaseErrorAsync(DatabaseErrorSuper['rdb.DatabaseAsync']):
386
385
  note : Exception note.
387
386
  """
388
387
 
389
- # Handle parameter.
388
+ # Set parameter.
390
389
  data = self.handle_record(exc, stack, note)
391
390
 
392
391
  # Insert.
@@ -413,7 +412,7 @@ class DatabaseErrorAsync(DatabaseErrorSuper['rdb.DatabaseAsync']):
413
412
  filter_type : Exception types of not insert, but still throw exception.
414
413
  """
415
414
 
416
- # Handle parameter.
415
+ # Set parameter.
417
416
  _, exc, stack = catch_exc()
418
417
 
419
418
  # Filter.
@@ -472,7 +471,7 @@ class DatabaseErrorAsync(DatabaseErrorSuper['rdb.DatabaseAsync']):
472
471
  >>> await func(*args, **kwargs)
473
472
  """
474
473
 
475
- # Handle parameter.
474
+ # Set parameter.
476
475
  if issubclass(filter_type, BaseException):
477
476
  filter_type = (filter_type,)
478
477
 
reydb/rexec.py CHANGED
@@ -87,7 +87,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
87
87
  Parameter `sql` and `data` and `report`.
88
88
  """
89
89
 
90
- # Handle parameter.
90
+ # Set parameter.
91
91
  echo = get_first_notnone(echo, self.conn.db.echo)
92
92
  sql = handle_sql(sql)
93
93
  if data is None:
@@ -142,7 +142,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
142
142
  Parameter `sql`.
143
143
  """
144
144
 
145
- # Handle parameter.
145
+ # Set parameter.
146
146
  if type(path) == str:
147
147
  database, table = self.conn.db.database, path
148
148
  else:
@@ -240,7 +240,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
240
240
  Parameter `sql` and `kwdata`.
241
241
  """
242
242
 
243
- # Handle parameter.
243
+ # Set parameter.
244
244
  if type(path) == str:
245
245
  database, table = self.conn.db.database, path
246
246
  else:
@@ -383,7 +383,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
383
383
  Parameter `sql` and `data`.
384
384
  """
385
385
 
386
- # Handle parameter.
386
+ # Set parameter.
387
387
  if type(path) == str:
388
388
  database, table = self.conn.db.database, path
389
389
  else:
@@ -517,7 +517,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
517
517
  Parameter `sql`.
518
518
  """
519
519
 
520
- # Handle parameter.
520
+ # Set parameter.
521
521
  if type(path) == str:
522
522
  database, table = self.conn.db.database, path
523
523
  else:
@@ -580,7 +580,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
580
580
  Parameter `sql`.
581
581
  """
582
582
 
583
- # Handle parameter.
583
+ # Set parameter.
584
584
  if type(path) == str:
585
585
  database, table = self.conn.db.database, path
586
586
  else:
@@ -658,7 +658,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
658
658
  Result object.
659
659
  """
660
660
 
661
- # Handle parameter.
661
+ # Set parameter.
662
662
  sql, data, echo = self.handle_execute(sql, data, echo, **kwdata)
663
663
 
664
664
  # Transaction.
@@ -755,7 +755,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
755
755
  [{'id': 1, 'id_': 2}, ...]
756
756
  """
757
757
 
758
- # Handle parameter.
758
+ # Set parameter.
759
759
  sql = self.handle_select(path, fields, where, group, having, order, limit)
760
760
 
761
761
  # Execute SQL.
@@ -808,7 +808,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
808
808
  [{'key': 'a', 'value1': 1, 'value2': 2}, {'key': 'b', 'value1': 1, 'value2': 2}]
809
809
  """
810
810
 
811
- # Handle parameter.
811
+ # Set parameter.
812
812
  sql, kwdata = self.handle_insert(path, data, duplicate, **kwdata)
813
813
 
814
814
  # Execute SQL.
@@ -867,7 +867,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
867
867
  [{'key': 'a', 'value': 1, 'name': 'a'}, {'key': 'b', 'value': 1, 'name': 'b'}]
868
868
  """
869
869
 
870
- # Handle parameter.
870
+ # Set parameter.
871
871
  sql, data = self.handle_update(path, data, where_fields, **kwdata)
872
872
 
873
873
  # Execute SQL.
@@ -913,7 +913,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
913
913
  2
914
914
  """
915
915
 
916
- # Handle parameter.
916
+ # Set parameter.
917
917
  sql = self.handle_delete(path, where, order, limit)
918
918
 
919
919
  # Execute SQL.
@@ -964,7 +964,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
964
964
  2
965
965
  """
966
966
 
967
- # Handle parameter.
967
+ # Set parameter.
968
968
  sql = self.handle_copy(path, fields, where, limit)
969
969
 
970
970
  # Execute SQL.
@@ -1145,7 +1145,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
1145
1145
  - When parameters `precision` is `greater than 0`, then return float.
1146
1146
  """
1147
1147
 
1148
- # Handle parameter.
1148
+ # Set parameter.
1149
1149
  if len(thresholds) == 1:
1150
1150
  second = thresholds[0]
1151
1151
  else:
@@ -1187,7 +1187,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1187
1187
  Result object.
1188
1188
  """
1189
1189
 
1190
- # Handle parameter.
1190
+ # Set parameter.
1191
1191
  sql, data, echo = self.handle_execute(sql, data, echo, **kwdata)
1192
1192
 
1193
1193
  # Transaction.
@@ -1301,7 +1301,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1301
1301
  [{'id': 1, 'id_': 2}, ...]
1302
1302
  """
1303
1303
 
1304
- # Handle parameter.
1304
+ # Set parameter.
1305
1305
  sql = self.handle_select(path, fields, where, group, having, order, limit)
1306
1306
 
1307
1307
  # Execute SQL.
@@ -1354,7 +1354,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1354
1354
  [{'key': 'a', 'value1': 1, 'value2': 2}, {'key': 'b', 'value1': 1, 'value2': 2}]
1355
1355
  """
1356
1356
 
1357
- # Handle parameter.
1357
+ # Set parameter.
1358
1358
  sql, kwdata = self.handle_insert(path, data, duplicate, **kwdata)
1359
1359
 
1360
1360
  # Execute SQL.
@@ -1413,7 +1413,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1413
1413
  [{'key': 'a', 'value': 1, 'name': 'a'}, {'key': 'b', 'value': 1, 'name': 'b'}]
1414
1414
  """
1415
1415
 
1416
- # Handle parameter.
1416
+ # Set parameter.
1417
1417
  sql, data = self.handle_update(path, data, where_fields, **kwdata)
1418
1418
 
1419
1419
  # Execute SQL.
@@ -1459,7 +1459,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1459
1459
  2
1460
1460
  """
1461
1461
 
1462
- # Handle parameter.
1462
+ # Set parameter.
1463
1463
  sql = self.handle_delete(path, where, order, limit)
1464
1464
 
1465
1465
  # Execute SQL.
@@ -1510,7 +1510,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1510
1510
  2
1511
1511
  """
1512
1512
 
1513
- # Handle parameter.
1513
+ # Set parameter.
1514
1514
  sql = self.handle_copy(path, fields, where, limit)
1515
1515
 
1516
1516
  # Execute SQL.
@@ -1689,7 +1689,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1689
1689
  - When parameters `precision` is `greater than 0`, then return float.
1690
1690
  """
1691
1691
 
1692
- # Handle parameter.
1692
+ # Set parameter.
1693
1693
  if len(thresholds) == 1:
1694
1694
  second = thresholds[0]
1695
1695
  else:
reydb/rinfo.py CHANGED
@@ -75,7 +75,7 @@ class DatabaseInformationSchemaSuper(DatabaseInformationBase, Generic[DatabaseT]
75
75
  Parameter `sql` and `filter_db`.
76
76
  """
77
77
 
78
- # Handle parameter.
78
+ # Set parameter.
79
79
  filter_db = (
80
80
  'information_schema',
81
81
  'performance_schema',
@@ -193,7 +193,7 @@ class DatabaseInformationSchemaSuper(DatabaseInformationBase, Generic[DatabaseT]
193
193
  Judge result.
194
194
  """
195
195
 
196
- # Handle parameter.
196
+ # Set parameter.
197
197
 
198
198
  # Judge.
199
199
  judge = (
@@ -298,7 +298,7 @@ class DatabaseInformationSchema(DatabaseInformationSchemaSuper['rdb.Database']):
298
298
  Judge result.
299
299
  """
300
300
 
301
- # Handle parameter.
301
+ # Set parameter.
302
302
  if (
303
303
  refresh
304
304
  or self.db._schema is None
@@ -395,7 +395,7 @@ class DatabaseInformationSchemaAsync(DatabaseInformationSchemaSuper['rdb.Databas
395
395
  Judge result.
396
396
  """
397
397
 
398
- # Handle parameter.
398
+ # Set parameter.
399
399
  if (
400
400
  refresh
401
401
  or self.db._schema is None
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.1
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=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