reydb 1.1.59__py3-none-any.whl → 1.1.60__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/rexec.py CHANGED
@@ -24,7 +24,7 @@ from reykit.rtime import TimeMark, time_to
24
24
  from reykit.rwrap import wrap_runtime
25
25
 
26
26
  from . import rconn
27
- from .rbase import DatabaseBase, handle_sql, handle_data
27
+ from .rbase import DatabaseBase, handle_sql, handle_data, extract_path
28
28
 
29
29
 
30
30
  __all__ = (
@@ -40,7 +40,7 @@ Result = Result_
40
40
  monkey_sqlalchemy_row_index_field()
41
41
 
42
42
 
43
- DatabaseConnectionT = TypeVar('DatabaseConnectionT')
43
+ DatabaseConnectionT = TypeVar('DatabaseConnectionT', 'rconn.DatabaseConnection', 'rconn.DatabaseConnectionAsync')
44
44
 
45
45
 
46
46
  class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
@@ -59,7 +59,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
59
59
  """
60
60
 
61
61
  # Build.
62
- self.dbconn = dbconn
62
+ self.conn = dbconn
63
63
 
64
64
 
65
65
  def handle_execute(
@@ -87,7 +87,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
87
87
  """
88
88
 
89
89
  # Handle parameter.
90
- report = get_first_notnone(report, self.dbconn.db.report)
90
+ report = get_first_notnone(report, self.conn.db.report)
91
91
  sql = handle_sql(sql)
92
92
  if data is None:
93
93
  if kwdata == {}:
@@ -119,7 +119,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
119
119
 
120
120
  Parameters
121
121
  ----------
122
- table : Table name.
122
+ table : Table name, can include database name.
123
123
  fields : Select clause content.
124
124
  - `None`: Is `SELECT *`.
125
125
  - `str`: Join as `SELECT str`.
@@ -139,6 +139,11 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
139
139
  Parameter `sql`.
140
140
  """
141
141
 
142
+ # Handle parameter.
143
+ database = self.conn.db.database
144
+ if '.' in table:
145
+ database, table, _ = extract_path(table)
146
+
142
147
  # Generate SQL.
143
148
  sql_list = []
144
149
 
@@ -161,7 +166,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
161
166
  sql_list.append(sql_select)
162
167
 
163
168
  ## Part 'FROM' syntax.
164
- sql_from = f'FROM `{self.dbconn.db.database}`.`{table}`'
169
+ sql_from = f'FROM `{database}`.`{table}`'
165
170
  sql_list.append(sql_from)
166
171
 
167
172
  ## Part 'WHERE' syntax.
@@ -213,7 +218,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
213
218
 
214
219
  Parameters
215
220
  ----------
216
- table : Table name.
221
+ table : Table name, can include database name.
217
222
  data : Insert data.
218
223
  duplicate : Handle method when constraint error.
219
224
  - `None`: Not handled.
@@ -230,6 +235,9 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
230
235
  """
231
236
 
232
237
  # Handle parameter.
238
+ database = self.conn.db.database
239
+ if '.' in table:
240
+ database, table, _ = extract_path(table)
233
241
 
234
242
  ## Data.
235
243
  data_table = Table(data)
@@ -296,14 +304,14 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
296
304
  ### Not handle.
297
305
  case None:
298
306
  sql = (
299
- f'INSERT INTO `{self.dbconn.db.database}`.`{table}`({sql_fields})\n'
307
+ f'INSERT INTO `{database}`.`{table}`({sql_fields})\n'
300
308
  f'VALUES({sql_values})'
301
309
  )
302
310
 
303
311
  ### Ignore.
304
312
  case 'ignore':
305
313
  sql = (
306
- f'INSERT IGNORE INTO `{self.dbconn.db.database}`.`{table}`({sql_fields})\n'
314
+ f'INSERT IGNORE INTO `{database}`.`{table}`({sql_fields})\n'
307
315
  f'VALUES({sql_values})'
308
316
  )
309
317
 
@@ -323,7 +331,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
323
331
  ]
324
332
  )
325
333
  sql = (
326
- f'INSERT INTO `{self.dbconn.db.database}`.`{table}`({sql_fields})\n'
334
+ f'INSERT INTO `{database}`.`{table}`({sql_fields})\n'
327
335
  f'VALUES({sql_values})\n'
328
336
  'ON DUPLICATE KEY UPDATE\n'
329
337
  f' {update_content}'
@@ -344,7 +352,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
344
352
 
345
353
  Parameters
346
354
  ----------
347
- table : Table name.
355
+ table : Table name, can include database name.
348
356
  data : Update data, clause `SET` and `WHERE` and `ORDER BY` and `LIMIT` content.
349
357
  - `Key`: Table field.
350
358
  `literal['order']`: Clause `ORDER BY` content, join as `ORDER BY str`.
@@ -367,6 +375,9 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
367
375
  """
368
376
 
369
377
  # Handle parameter.
378
+ database = self.conn.db.database
379
+ if '.' in table:
380
+ database, table, _ = extract_path(table)
370
381
 
371
382
  ## Data.
372
383
  data_table = Table(data)
@@ -408,7 +419,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
408
419
  if type(where_fields) == str:
409
420
  where_fields = [where_fields]
410
421
  sqls_list = []
411
- sql_update = f'UPDATE `{self.dbconn.db.database}`.`{table}`'
422
+ sql_update = f'UPDATE `{database}`.`{table}`'
412
423
  for index, row in enumerate(data):
413
424
  sql_parts = [sql_update]
414
425
  for key, value in row.items():
@@ -484,7 +495,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
484
495
 
485
496
  Parameters
486
497
  ----------
487
- table : Table name.
498
+ table : Table name, can include database name.
488
499
  where : Clause `WHERE` content, join as `WHERE str`.
489
500
  order : Clause `ORDER BY` content, join as `ORDER BY str`.
490
501
  limit : Clause `LIMIT` content, join as `LIMIT int/str`.
@@ -494,11 +505,16 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
494
505
  Parameter `sql`.
495
506
  """
496
507
 
508
+ # Handle parameter.
509
+ database = self.conn.db.database
510
+ if '.' in table:
511
+ database, table, _ = extract_path(table)
512
+
497
513
  # Generate SQL.
498
514
  sqls = []
499
515
 
500
516
  ## Part 'DELETE' syntax.
501
- sql_delete = f'DELETE FROM `{self.dbconn.db.database}`.`{table}`'
517
+ sql_delete = f'DELETE FROM `{database}`.`{table}`'
502
518
  sqls.append(sql_delete)
503
519
 
504
520
  ## Part 'WHERE' syntax.
@@ -534,7 +550,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
534
550
 
535
551
  Parameters
536
552
  ----------
537
- table : Table name.
553
+ table : Table name, can include database name.
538
554
  where : Clause `WHERE` content, join as `WHERE str`.
539
555
  limit : Clause `LIMIT` content.
540
556
  - `int | str`: Join as `LIMIT int/str`.
@@ -551,7 +567,10 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
551
567
  """
552
568
 
553
569
  # Handle parameter.
554
- table_info: list[dict] = self.dbconn.db.info(self.dbconn.db.database)(table)()
570
+ database = self.conn.db.database
571
+ if '.' in table:
572
+ database, table, _ = extract_path(table)
573
+ table_info: list[dict] = self.conn.db.info(database)(table)()
555
574
  field_key = 'COLUMN_NAME'
556
575
  fields = [
557
576
  row[field_key]
@@ -586,7 +605,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
586
605
  )
587
606
  )
588
607
  sql_fields = ', '.join(sql_fields_filter)
589
- sql_insert = f'INSERT INTO `{self.dbconn.db.database}`.`{table}`({sql_fields})'
608
+ sql_insert = f'INSERT INTO `{database}`.`{table}`({sql_fields})'
590
609
  sqls.append(sql_insert)
591
610
 
592
611
  ## Part 'SELECT' syntax.
@@ -617,7 +636,7 @@ class DatabaseExecuteSuper(DatabaseBase, Generic[DatabaseConnectionT]):
617
636
  sql_values = ', '.join(sql_values_filter)
618
637
  sql_select = (
619
638
  f'SELECT {sql_values}\n'
620
- f'FROM `{self.dbconn.db.database}`.`{table}`'
639
+ f'FROM `{database}`.`{table}`'
621
640
  )
622
641
  sqls.append(sql_select)
623
642
 
@@ -677,13 +696,13 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
677
696
  sql, data, report = self.handle_execute(sql, data, report, **kwdata)
678
697
 
679
698
  # Transaction.
680
- self.dbconn.get_begin()
699
+ self.conn.get_begin()
681
700
 
682
701
  # Execute.
683
702
 
684
703
  ## Report.
685
704
  if report:
686
- execute = wrap_runtime(self.dbconn.execute, to_return=True)
705
+ execute = wrap_runtime(self.conn.connection.execute, to_return=True, to_print=False)
687
706
  result, report_runtime, *_ = execute(sql, data)
688
707
  report_info = (
689
708
  f'{report_runtime}\n'
@@ -701,12 +720,12 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
701
720
 
702
721
  ## Not report.
703
722
  else:
704
- result = self.dbconn.conn.execute(sql, data)
723
+ result = self.conn.connection.execute(sql, data)
705
724
 
706
725
  # Automatic commit.
707
- if self.dbconn.autocommit:
708
- self.dbconn.commit()
709
- self.dbconn.close()
726
+ if self.conn.autocommit:
727
+ self.conn.commit()
728
+ self.conn.close()
710
729
 
711
730
  return result
712
731
 
@@ -731,7 +750,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
731
750
 
732
751
  Parameters
733
752
  ----------
734
- table : Table name.
753
+ table : Table name, can include database name.
735
754
  fields : Select clause content.
736
755
  - `None`: Is `SELECT *`.
737
756
  - `str`: Join as `SELECT str`.
@@ -790,7 +809,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
790
809
 
791
810
  Parameters
792
811
  ----------
793
- table : Table name.
812
+ table : Table name, can include database name.
794
813
  data : Insert data.
795
814
  duplicate : Handle method when constraint error.
796
815
  - `None`: Not handled.
@@ -842,7 +861,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
842
861
 
843
862
  Parameters
844
863
  ----------
845
- table : Table name.
864
+ table : Table name, can include database name.
846
865
  data : Update data, clause `SET` and `WHERE` and `ORDER BY` and `LIMIT` content.
847
866
  - `Key`: Table field.
848
867
  `literal['order']`: Clause `ORDER BY` content, join as `ORDER BY str`.
@@ -901,7 +920,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
901
920
 
902
921
  Parameters
903
922
  ----------
904
- table : Table name.
923
+ table : Table name, can include database name.
905
924
  where : Clause `WHERE` content, join as `WHERE str`.
906
925
  order : Clause `ORDER BY` content, join as `ORDER BY str`.
907
926
  limit : Clause `LIMIT` content, join as `LIMIT int/str`.
@@ -945,7 +964,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
945
964
 
946
965
  Parameters
947
966
  ----------
948
- table : Table name.
967
+ table : Table name, can include database name.
949
968
  where : Clause `WHERE` content, join as `WHERE str`.
950
969
  limit : Clause `LIMIT` content.
951
970
  - `int | str`: Join as `LIMIT int/str`.
@@ -993,7 +1012,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
993
1012
 
994
1013
  Parameters
995
1014
  ----------
996
- table : Table name.
1015
+ table : Table name, can include database name.
997
1016
  where : Match condition, `WHERE` clause content, join as `WHERE str`.
998
1017
  - `None`: Match all.
999
1018
  - `str`: Match condition.
@@ -1034,7 +1053,7 @@ class DatabaseExecute(DatabaseExecuteSuper['rconn.DatabaseConnection']):
1034
1053
 
1035
1054
  Parameters
1036
1055
  ----------
1037
- table : Table name.
1056
+ table : Table name, can include database name.
1038
1057
  where : Match condition, `WHERE` clause content, join as `WHERE str`.
1039
1058
  - `None`: Match all.
1040
1059
  - `str`: Match condition.
@@ -1198,7 +1217,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1198
1217
  sql, data, report = self.handle_execute(sql, data, report, **kwdata)
1199
1218
 
1200
1219
  # Transaction.
1201
- await self.dbconn.get_begin()
1220
+ await self.conn.get_begin()
1202
1221
 
1203
1222
  # Execute.
1204
1223
 
@@ -1206,7 +1225,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1206
1225
  if report:
1207
1226
  tm = TimeMark()
1208
1227
  tm()
1209
- result = await self.dbconn.conn.execute(sql, data)
1228
+ result = await self.conn.connection.execute(sql, data)
1210
1229
  tm()
1211
1230
 
1212
1231
  ### Generate report.
@@ -1238,13 +1257,13 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1238
1257
 
1239
1258
  ## Not report.
1240
1259
  else:
1241
- result = await self.dbconn.conn.execute(sql, data)
1260
+ result = await self.conn.connection.execute(sql, data)
1242
1261
 
1243
1262
  # Automatic commit.
1244
- if self.dbconn.autocommit:
1245
- await self.dbconn.commit()
1246
- await self.dbconn.close()
1247
- await self.dbconn.db.dispose()
1263
+ if self.conn.autocommit:
1264
+ await self.conn.commit()
1265
+ await self.conn.close()
1266
+ await self.conn.db.dispose()
1248
1267
 
1249
1268
  return result
1250
1269
 
@@ -1269,7 +1288,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1269
1288
 
1270
1289
  Parameters
1271
1290
  ----------
1272
- table : Table name.
1291
+ table : Table name, can include database name.
1273
1292
  fields : Select clause content.
1274
1293
  - `None`: Is `SELECT *`.
1275
1294
  - `str`: Join as `SELECT str`.
@@ -1328,7 +1347,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1328
1347
 
1329
1348
  Parameters
1330
1349
  ----------
1331
- table : Table name.
1350
+ table : Table name, can include database name.
1332
1351
  data : Insert data.
1333
1352
  duplicate : Handle method when constraint error.
1334
1353
  - `None`: Not handled.
@@ -1380,7 +1399,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1380
1399
 
1381
1400
  Parameters
1382
1401
  ----------
1383
- table : Table name.
1402
+ table : Table name, can include database name.
1384
1403
  data : Update data, clause `SET` and `WHERE` and `ORDER BY` and `LIMIT` content.
1385
1404
  - `Key`: Table field.
1386
1405
  `literal['order']`: Clause `ORDER BY` content, join as `ORDER BY str`.
@@ -1439,7 +1458,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1439
1458
 
1440
1459
  Parameters
1441
1460
  ----------
1442
- table : Table name.
1461
+ table : Table name, can include database name.
1443
1462
  where : Clause `WHERE` content, join as `WHERE str`.
1444
1463
  order : Clause `ORDER BY` content, join as `ORDER BY str`.
1445
1464
  limit : Clause `LIMIT` content, join as `LIMIT int/str`.
@@ -1483,7 +1502,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1483
1502
 
1484
1503
  Parameters
1485
1504
  ----------
1486
- table : Table name.
1505
+ table : Table name, can include database name.
1487
1506
  where : Clause `WHERE` content, join as `WHERE str`.
1488
1507
  limit : Clause `LIMIT` content.
1489
1508
  - `int | str`: Join as `LIMIT int/str`.
@@ -1531,7 +1550,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1531
1550
 
1532
1551
  Parameters
1533
1552
  ----------
1534
- table : Table name.
1553
+ table : Table name, can include database name.
1535
1554
  where : Match condition, `WHERE` clause content, join as `WHERE str`.
1536
1555
  - `None`: Match all.
1537
1556
  - `str`: Match condition.
@@ -1572,7 +1591,7 @@ class DatabaseExecuteAsync(DatabaseExecuteSuper['rconn.DatabaseConnectionAsync']
1572
1591
 
1573
1592
  Parameters
1574
1593
  ----------
1575
- table : Table name.
1594
+ table : Table name, can include database name.
1576
1595
  where : Match condition, `WHERE` clause content, join as `WHERE str`.
1577
1596
  - `None`: Match all.
1578
1597
  - `str`: Match condition.
reydb/rfile.py CHANGED
@@ -56,7 +56,7 @@ class DatabaseFile(DatabaseBase):
56
56
 
57
57
  def build_db(self) -> None:
58
58
  """
59
- Check and build all standard databases and tables, by `self.db_names`.
59
+ Check and build database tables, by `self.db_names`.
60
60
  """
61
61
 
62
62
  # Set parameter.
@@ -327,7 +327,7 @@ class DatabaseFile(DatabaseBase):
327
327
 
328
328
  # Exist.
329
329
  exist = conn.execute.exist(
330
- (self.db_names['file'], self.db_names['file.data']),
330
+ self.db_names['file.data'],
331
331
  '`md5` = :file_md5',
332
332
  file_md5=file_md5
333
333
  )
@@ -342,7 +342,7 @@ class DatabaseFile(DatabaseBase):
342
342
  'bytes': file_bytes
343
343
  }
344
344
  conn.execute.insert(
345
- (self.db_names['file'], self.db_names['file.data']),
345
+ self.db_names['file.data'],
346
346
  data,
347
347
  'ignore'
348
348
  )
@@ -354,7 +354,7 @@ class DatabaseFile(DatabaseBase):
354
354
  'note': note
355
355
  }
356
356
  conn.execute.insert(
357
- (self.db_names['file'], self.db_names['file.information']),
357
+ self.db_names['file.information'],
358
358
  data
359
359
  )
360
360
 
reydb/rorm.py CHANGED
@@ -29,12 +29,6 @@ from . import rdb
29
29
  from .rbase import (
30
30
  SessionT,
31
31
  SessionTransactionT,
32
- DatabaseT,
33
- DatabaseORMT,
34
- DatabaseORMStatementSelectT,
35
- DatabaseORMStatementInsertT,
36
- DatabaseORMStatementUpdateT,
37
- DatabaseORMStatementDeleteT,
38
32
  DatabaseBase
39
33
  )
40
34
 
@@ -64,9 +58,15 @@ __all__ = (
64
58
  )
65
59
 
66
60
 
61
+ DatabaseT = TypeVar('DatabaseT', 'rdb.Database', 'rdb.DatabaseAsync')
67
62
  DatabaseORMModelT = TypeVar('DatabaseORMModelT', bound='DatabaseORMModel')
63
+ DatabaseORMT = TypeVar('DatabaseORMT', 'DatabaseORM', 'DatabaseORMAsync')
68
64
  DatabaseORMSessionT = TypeVar('DatabaseORMSessionT', 'DatabaseORMSession', 'DatabaseORMSessionAsync')
69
65
  DatabaseORMStatementReturn = TypeVar('DatabaseORMStatementReturn')
66
+ DatabaseORMStatementSelectT = TypeVar('DatabaseORMStatementSelectT', 'DatabaseORMStatementSelect', 'DatabaseORMStatementSelectAsync')
67
+ DatabaseORMStatementInsertT = TypeVar('DatabaseORMStatementInsertT', 'DatabaseORMStatementInsert', 'DatabaseORMStatementInsertAsync')
68
+ DatabaseORMStatementUpdateT = TypeVar('DatabaseORMStatementUpdateT', 'DatabaseORMStatementUpdate', 'DatabaseORMStatementUpdateAsync')
69
+ DatabaseORMStatementDeleteT = TypeVar('DatabaseORMStatementDeleteT', 'DatabaseORMStatementDelete', 'DatabaseORMStatementDeleteAsync')
70
70
 
71
71
 
72
72
  class DatabaseORMBase(DatabaseBase):
@@ -103,6 +103,16 @@ class DatabaseORMModelMeta(DatabaseORMBase, SQLModelMetaclass):
103
103
  if attrs['__module__'] == '__main__':
104
104
  table_args = attrs.setdefault('__table_args__', {})
105
105
  table_args['quote'] = True
106
+
107
+ ## Charset.
108
+ attrs.setdefault('__charset__', 'utf8mb4')
109
+ table_args['mysql_charset'] = attrs.pop('__charset__')
110
+
111
+ ## Name.
112
+ if '__name__' in attrs:
113
+ table_args['name'] = attrs.pop('__name__')
114
+
115
+ ## Comment.
106
116
  if '__comment__' in attrs:
107
117
  table_args['comment'] = attrs.pop('__comment__')
108
118
 
@@ -244,7 +254,7 @@ class DatabaseORMModelField(DatabaseBase, FieldInfo):
244
254
  field_type: TypeEngine | None = None,
245
255
  key: bool = False,
246
256
  key_auto: bool = False,
247
- non_null: bool = False,
257
+ not_null: bool = False,
248
258
  index_n: bool = False,
249
259
  index_u: bool = False,
250
260
  comment: str | None = None,
@@ -282,7 +292,7 @@ class DatabaseORMModelField(DatabaseBase, FieldInfo):
282
292
  - `None`: Based type annotation automatic judgment.
283
293
  key : Whether the field is primary key.
284
294
  key_auto : Whether the field is automatic increment primary key.
285
- non_null : Whether the field is non null constraint.
295
+ not_null : Whether the field is not null constraint.
286
296
  index_n : Whether the field add normal index.
287
297
  index_u : Whether the field add unique index.
288
298
  comment : Field commment.
@@ -363,8 +373,8 @@ class DatabaseORMModelField(DatabaseBase, FieldInfo):
363
373
  kwargs['sa_column_kwargs']['autoincrement'] = False
364
374
 
365
375
  ## Non null.
366
- if 'non_null' in kwargs:
367
- kwargs['nullable'] = not kwargs.pop('non_null')
376
+ if 'not_null' in kwargs:
377
+ kwargs['nullable'] = not kwargs.pop('not_null')
368
378
  else:
369
379
  kwargs['nullable'] = True
370
380
 
@@ -395,7 +405,7 @@ class DatabaseORMSuper(DatabaseORMBase, Generic[DatabaseT, DatabaseORMSessionT])
395
405
  Model = DatabaseORMModel
396
406
  Field = DatabaseORMModelField
397
407
  Config = ConfigDict
398
- tyeps = sqltypes
408
+ types = sqltypes
399
409
  wrap_validate_model = pydantic_model_validator
400
410
  wrap_validate_filed = pydantic_field_validator
401
411
 
@@ -792,12 +802,12 @@ class DatabaseORMSession(
792
802
  skip: bool = False
793
803
  ) -> None:
794
804
  """
795
- Create table.
805
+ Create tables.
796
806
 
797
807
  Parameters
798
808
  ----------
799
809
  models : ORM model instances.
800
- skip : Skip existing table.
810
+ skip : Whether skip existing table.
801
811
  """
802
812
 
803
813
  # Handle parameter.
@@ -821,7 +831,7 @@ class DatabaseORMSession(
821
831
  skip: bool = False
822
832
  ) -> None:
823
833
  """
824
- Delete table.
834
+ Delete tables.
825
835
 
826
836
  Parameters
827
837
  ----------
@@ -839,7 +849,7 @@ class DatabaseORMSession(
839
849
  if None in tables:
840
850
  throw(ValueError, tables)
841
851
 
842
- # Create.
852
+ # Drop.
843
853
  self.orm.metaData.drop_all(self.orm.db.engine, tables, skip)
844
854
 
845
855
 
@@ -1158,12 +1168,12 @@ class DatabaseORMSessionAsync(
1158
1168
  skip: bool = False
1159
1169
  ) -> None:
1160
1170
  """
1161
- Asynchronous create table.
1171
+ Asynchronous create tables.
1162
1172
 
1163
1173
  Parameters
1164
1174
  ----------
1165
1175
  models : ORM model instances.
1166
- skip : Skip existing table.
1176
+ skip : Whether skip existing table.
1167
1177
  """
1168
1178
 
1169
1179
  # Handle parameter.
@@ -1188,7 +1198,7 @@ class DatabaseORMSessionAsync(
1188
1198
  skip: bool = False
1189
1199
  ) -> None:
1190
1200
  """
1191
- Asynchronous delete table.
1201
+ Asynchronous delete tables.
1192
1202
 
1193
1203
  Parameters
1194
1204
  ----------
@@ -1206,7 +1216,7 @@ class DatabaseORMSessionAsync(
1206
1216
  if None in tables:
1207
1217
  throw(ValueError, tables)
1208
1218
 
1209
- # Create.
1219
+ # Drop.
1210
1220
  conn = await self.sess.connection()
1211
1221
  await conn.run_sync(self.orm.metaData.drop_all, tables, skip)
1212
1222
 
reydb/rparam.py CHANGED
@@ -9,10 +9,10 @@
9
9
  """
10
10
 
11
11
 
12
- from typing import Generic, overload
12
+ from typing import TypeVar, Generic, overload
13
13
 
14
14
  from . import rdb
15
- from .rbase import DatabaseT, DatabaseBase
15
+ from .rbase import DatabaseBase
16
16
  from .rexec import Result
17
17
 
18
18
 
@@ -24,6 +24,9 @@ __all__ = (
24
24
  )
25
25
 
26
26
 
27
+ DatabaseT = TypeVar('DatabaseT', 'rdb.Database', 'rdb.DatabaseAsync')
28
+
29
+
27
30
  class DatabaseSchemaSuper(DatabaseBase, Generic[DatabaseT]):
28
31
  """
29
32
  Database schema super type.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reydb
3
- Version: 1.1.59
3
+ Version: 1.1.60
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,17 @@
1
+ reydb/__init__.py,sha256=h6duExQWsPCz3qKnTIHTslmqcBC63HCQvwiumg8oCVc,620
2
+ reydb/rall.py,sha256=GsXHqvT1k--U53HpDY4SALjIHN8rwgSxeXpJjH5gq2E,409
3
+ reydb/rbase.py,sha256=16fG_YWnvJFu0ElXvc3BS9PtSJFZ9M631Te0b2ewWDE,9457
4
+ reydb/rbuild.py,sha256=72faSm2mrtjeWqLSxiXkeG5fg0XB25mNo2MBFotE9m8,46413
5
+ reydb/rconfig.py,sha256=LWm3aTypt1u7zMmdq0p4K8d6JgT3hfWd_3RAlj3jS0I,10921
6
+ reydb/rconn.py,sha256=guRaR8N6RuzZzujwaeq7HhKWTizF9SrUBqEAFjfjpoo,6909
7
+ reydb/rdb.py,sha256=VM7nY-oynRWh4tFa2ZhXyJQ2Dm_cZbU2UVyW9e5NtFA,12460
8
+ reydb/rerror.py,sha256=309PJVQG7jsL2A2R5IW4zuS4IojBgoGx3qxwIotBh_k,9896
9
+ reydb/rexec.py,sha256=0w9BpgKm9uF7kwHtYM2vE9NK_s4ZbbLTQ4IBMYZqjn8,53973
10
+ reydb/rfile.py,sha256=usK1W39O3Fi7FoAljhDIFgqj15c1GrQv3ASYUt1IxdA,15087
11
+ reydb/rinfo.py,sha256=qW9QoGuMaMO2Fr76FCETE0TES_4CscagAceZtXc2qsU,12749
12
+ reydb/rorm.py,sha256=4Xq6Dfc3525FmZWFw_pkbNSn60nN0FKr5RlpBEIEDpo,39754
13
+ reydb/rparam.py,sha256=-uACeJvzMBQuQqa_F_AnGD9GoEoQEjjTnJ0dVZhA2to,9702
14
+ reydb-1.1.60.dist-info/METADATA,sha256=jIL2Go1IxL7mK8OT05Q4rfiE1z9Q0Z6e6qsjsO1L2EE,1622
15
+ reydb-1.1.60.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ reydb-1.1.60.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
17
+ reydb-1.1.60.dist-info/RECORD,,
@@ -1,17 +0,0 @@
1
- reydb/__init__.py,sha256=h6duExQWsPCz3qKnTIHTslmqcBC63HCQvwiumg8oCVc,620
2
- reydb/rall.py,sha256=GsXHqvT1k--U53HpDY4SALjIHN8rwgSxeXpJjH5gq2E,409
3
- reydb/rbase.py,sha256=Bc9upS6nRCYH05Js-UQrq6Fn3BDchD_TMO87h9o44Mg,10010
4
- reydb/rbuild.py,sha256=agCVP5MehdAkNGevOdioZgagFZyNxAjMHuKn7jIxTCg,31848
5
- reydb/rconfig.py,sha256=4-SRhwhd3GqGiRhwbAjCfxVz6tBOQ2ab6n_lrb35rUE,12694
6
- reydb/rconn.py,sha256=T4FdgycCeGg2HU6L1AQm3KFwpqCpxNA0r8-la4ETBio,6523
7
- reydb/rdb.py,sha256=GpBNmqbU0Tc4PPfgiQexPAEkQBxzfKKW-9Fh_iAGqkw,11772
8
- reydb/rerror.py,sha256=f713YXSwWgls5352KvvX9LiTT_PcsPjZcSjZnFbFbVo,9939
9
- reydb/rexec.py,sha256=o-VnFDprMeaQlQIX5_cHXHHchR5hRHWeJuFIqhVjBQ0,52835
10
- reydb/rfile.py,sha256=N-uJRT2PFDNv1gKyHAb9t8n8xPOdic3SpzML-C0Bi-0,15180
11
- reydb/rinfo.py,sha256=qW9QoGuMaMO2Fr76FCETE0TES_4CscagAceZtXc2qsU,12749
12
- reydb/rorm.py,sha256=_q73ELHTN6C-xXMFwywgqvojXIus3aj48vZzSnFu5YQ,38924
13
- reydb/rparam.py,sha256=2S3uuZ42ieGbc-0W202h6aM-chDMbp4qr-AWzOtk7vk,9629
14
- reydb-1.1.59.dist-info/METADATA,sha256=msmEqxR0LkoXeH_vwtS9vmlqn4u_UTBkE7rL4j5pTQ4,1622
15
- reydb-1.1.59.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- reydb-1.1.59.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
17
- reydb-1.1.59.dist-info/RECORD,,
File without changes