reydb 1.2.19__py3-none-any.whl → 1.2.20__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/__init__.py CHANGED
@@ -2,7 +2,7 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  """
5
- @Time : 2024-01-07 20:51:57
5
+ @Time : 2024-01-07
6
6
  @Author : Rey
7
7
  @Contact : reyxbo@163.com
8
8
  @Explain : Backend database method set.
@@ -15,6 +15,7 @@ rbuild : Database build methods.
15
15
  rconfig : Database config methods.
16
16
  rconn : Database connection methods.
17
17
  rdb : Database methods.
18
+ rengine : Database engine methods.
18
19
  rerror : Database error methods.
19
20
  rexec : Database execute methods.
20
21
  rorm : Database ORM methods.
@@ -23,3 +24,4 @@ rinfo : Database information methods.
23
24
 
24
25
 
25
26
  from .rdb import Database, DatabaseAsync
27
+ from .rengine import DatabaseEngine, DatabaseEngineAsync
reydb/rall.py CHANGED
@@ -2,7 +2,7 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  """
5
- @Time : 2024-01-07 20:50:02
5
+ @Time : 2024-01-07
6
6
  @Author : Rey
7
7
  @Contact : reyxbo@163.com
8
8
  @Explain : All methods.
@@ -14,6 +14,7 @@ from .rbuild import *
14
14
  from .rconfig import *
15
15
  from .rconn import *
16
16
  from .rdb import *
17
+ from .rengine import *
17
18
  from .rerror import *
18
19
  from .rexec import *
19
20
  from .rorm import *
reydb/rbase.py CHANGED
@@ -2,7 +2,7 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  """
5
- @Time : 2025-07-18 23:36:56
5
+ @Time : 2025-07-18
6
6
  @Author : Rey
7
7
  @Contact : reyxbo@163.com
8
8
  @Explain : Base methods.
reydb/rbuild.py CHANGED
@@ -2,7 +2,7 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  """
5
- @Time : 2023-10-14 23:05:35
5
+ @Time : 2023-10-14
6
6
  @Author : Rey
7
7
  @Contact : reyxbo@163.com
8
8
  @Explain : Database build methods.
@@ -15,7 +15,7 @@ from sqlalchemy import UniqueConstraint
15
15
  from reykit.rbase import throw, is_instance
16
16
  from reykit.rstdout import ask
17
17
 
18
- from . import rdb
18
+ from . import rengine
19
19
  from .rbase import DatabaseBase
20
20
  from .rorm import DatabaseORMModel
21
21
 
@@ -47,26 +47,26 @@ IndexSet = TypedDict(
47
47
  'comment': NotRequired[str | None]
48
48
  }
49
49
  )
50
- DatabaseT = TypeVar('DatabaseT', 'rdb.Database', 'rdb.DatabaseAsync')
50
+ DatabaseEngineT = TypeVar('DatabaseEngineT', 'rengine.DatabaseEngine', 'rengine.DatabaseEngineAsync')
51
51
 
52
52
 
53
- class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
53
+ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseEngineT]):
54
54
  """
55
55
  Database build super type.
56
56
  """
57
57
 
58
58
 
59
- def __init__(self, db: DatabaseT) -> None:
59
+ def __init__(self, engine: DatabaseEngineT) -> None:
60
60
  """
61
61
  Build instance attributes.
62
62
 
63
63
  Parameters
64
64
  ----------
65
- db: Database instance.
65
+ engine: Database engine.
66
66
  """
67
67
 
68
68
  # Set attribute.
69
- self.db = db
69
+ self.engine = engine
70
70
 
71
71
 
72
72
  def get_sql_create_database(
@@ -278,7 +278,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
278
278
 
279
279
  # Parameter.
280
280
  if type(path) == str:
281
- database, table = self.db.database, path
281
+ database, table = self.engine.database, path
282
282
  else:
283
283
  database, table = path
284
284
  if fields.__class__ == dict:
@@ -366,7 +366,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
366
366
 
367
367
  # Parameter.
368
368
  if type(path) == str:
369
- database, table = self.db.database, path
369
+ database, table = self.engine.database, path
370
370
  else:
371
371
  database, table = path
372
372
 
@@ -481,7 +481,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
481
481
 
482
482
  # Parameter.
483
483
  if type(path) == str:
484
- database, table = self.db.database, path
484
+ database, table = self.engine.database, path
485
485
  else:
486
486
  database, table = path
487
487
 
@@ -512,7 +512,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
512
512
 
513
513
  # Parameter.
514
514
  if type(path) == str:
515
- database, table = self.db.database, path
515
+ database, table = self.engine.database, path
516
516
  else:
517
517
  database, table = path
518
518
 
@@ -619,7 +619,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
619
619
 
620
620
  # Parameter.
621
621
  if type(path) == str:
622
- database, table = self.db.database, path
622
+ database, table = self.engine.database, path
623
623
  else:
624
624
  database, table = path
625
625
  if fields.__class__ == dict:
@@ -707,7 +707,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
707
707
 
708
708
  # Parameter.
709
709
  if type(path) == str:
710
- database, table = self.db.database, path
710
+ database, table = self.engine.database, path
711
711
  else:
712
712
  database, table = path
713
713
  if fields.__class__ == str:
@@ -795,7 +795,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
795
795
 
796
796
  # Parameter.
797
797
  if type(path) == str:
798
- database, table = self.db.database, path
798
+ database, table = self.engine.database, path
799
799
  else:
800
800
  database, table = path
801
801
  if fields.__class__ == dict:
@@ -889,7 +889,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
889
889
 
890
890
  # Parameter.
891
891
  if type(path) == str:
892
- database, table = self.db.database, path
892
+ database, table = self.engine.database, path
893
893
  else:
894
894
  database, table = path
895
895
 
@@ -920,7 +920,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
920
920
 
921
921
  # Parameter.
922
922
  if type(path) == str:
923
- database, table = self.db.database, path
923
+ database, table = self.engine.database, path
924
924
  else:
925
925
  database, table = path
926
926
 
@@ -985,7 +985,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
985
985
 
986
986
  # Get.
987
987
  table = model._get_table()
988
- text = f'TABLE `{self.db.database}`.`{table}`'
988
+ text = f'TABLE `{self.engine.database}`.`{table}`'
989
989
  if 'mysql_charset' in table.kwargs:
990
990
  text += f" | CHARSET '{table.kwargs['mysql_charset']}'"
991
991
  if table.comment:
@@ -1055,7 +1055,7 @@ class DatabaseBuildSuper(DatabaseBase, Generic[DatabaseT]):
1055
1055
  return text
1056
1056
 
1057
1057
 
1058
- class DatabaseBuild(DatabaseBuildSuper['rdb.Database']):
1058
+ class DatabaseBuild(DatabaseBuildSuper['rengine.DatabaseEngine']):
1059
1059
  """
1060
1060
  Database build type.
1061
1061
  """
@@ -1076,7 +1076,7 @@ class DatabaseBuild(DatabaseBuildSuper['rdb.Database']):
1076
1076
  """
1077
1077
 
1078
1078
  # Create.
1079
- self.db.orm.create(*models, skip=skip)
1079
+ self.engine.orm.create(*models, skip=skip)
1080
1080
 
1081
1081
 
1082
1082
  def drop_orm_table(
@@ -1094,7 +1094,7 @@ class DatabaseBuild(DatabaseBuildSuper['rdb.Database']):
1094
1094
  """
1095
1095
 
1096
1096
  # Drop.
1097
- self.db.orm.drop(*models, skip=skip)
1097
+ self.engine.orm.drop(*models, skip=skip)
1098
1098
 
1099
1099
 
1100
1100
  def build(
@@ -1133,7 +1133,7 @@ class DatabaseBuild(DatabaseBuildSuper['rdb.Database']):
1133
1133
  ## Exist.
1134
1134
  if (
1135
1135
  skip
1136
- and self.db.schema.exist(database)
1136
+ and self.engine.schema.exist(database)
1137
1137
  ):
1138
1138
  continue
1139
1139
 
@@ -1145,7 +1145,7 @@ class DatabaseBuild(DatabaseBuildSuper['rdb.Database']):
1145
1145
  self.input_confirm_build(sql)
1146
1146
 
1147
1147
  ## Execute.
1148
- self.db.execute(sql)
1148
+ self.engine.execute(sql)
1149
1149
 
1150
1150
  ## Report.
1151
1151
  text = f"Database '{database}' build completed."
@@ -1158,14 +1158,14 @@ class DatabaseBuild(DatabaseBuildSuper['rdb.Database']):
1158
1158
  if type(params) == dict:
1159
1159
  path: str | tuple[str, str] = params['path']
1160
1160
  if type(path) == str:
1161
- database, table = self.db.database, path
1161
+ database, table = self.engine.database, path
1162
1162
  else:
1163
1163
  database, table = path
1164
1164
 
1165
1165
  ### Exist.
1166
1166
  if (
1167
1167
  skip
1168
- and self.db.schema.exist(database, table)
1168
+ and self.engine.schema.exist(database, table)
1169
1169
  ):
1170
1170
  continue
1171
1171
 
@@ -1177,17 +1177,17 @@ class DatabaseBuild(DatabaseBuildSuper['rdb.Database']):
1177
1177
  self.input_confirm_build(sql)
1178
1178
 
1179
1179
  ### Execute.
1180
- self.db.execute(sql)
1180
+ self.engine.execute(sql)
1181
1181
 
1182
1182
  ## ORM.
1183
1183
  else:
1184
- database = self.db.database
1184
+ database = self.engine.database
1185
1185
  table = params._get_table().name
1186
1186
 
1187
1187
  ## Exist.
1188
1188
  if (
1189
1189
  skip
1190
- and self.db.schema.exist(self.db.database, table)
1190
+ and self.engine.schema.exist(self.engine.database, table)
1191
1191
  ):
1192
1192
  continue
1193
1193
 
@@ -1206,20 +1206,20 @@ class DatabaseBuild(DatabaseBuildSuper['rdb.Database']):
1206
1206
 
1207
1207
  # Refresh schema.
1208
1208
  if refresh_schema:
1209
- self.db.schema()
1209
+ self.engine.schema()
1210
1210
 
1211
1211
  # View.
1212
1212
  for params in views:
1213
1213
  path = params['path']
1214
1214
  if type(path) == str:
1215
- database, table = self.db.database, path
1215
+ database, table = self.engine.database, path
1216
1216
  else:
1217
1217
  database, table = path
1218
1218
 
1219
1219
  ## Exist.
1220
1220
  if (
1221
1221
  skip
1222
- and self.db.schema.exist(database, table)
1222
+ and self.engine.schema.exist(database, table)
1223
1223
  ):
1224
1224
  continue
1225
1225
 
@@ -1231,7 +1231,7 @@ class DatabaseBuild(DatabaseBuildSuper['rdb.Database']):
1231
1231
  self.input_confirm_build(sql)
1232
1232
 
1233
1233
  ## Execute.
1234
- self.db.execute(sql)
1234
+ self.engine.execute(sql)
1235
1235
 
1236
1236
  ## Report.
1237
1237
  text = f"View '{table}' of database '{database}' build completed."
@@ -1241,14 +1241,14 @@ class DatabaseBuild(DatabaseBuildSuper['rdb.Database']):
1241
1241
  for params in views_stats:
1242
1242
  path = params['path']
1243
1243
  if type(path) == str:
1244
- database, table = self.db.database, path
1244
+ database, table = self.engine.database, path
1245
1245
  else:
1246
1246
  database, table = path
1247
1247
 
1248
1248
  ## Exist.
1249
1249
  if (
1250
1250
  skip
1251
- and self.db.schema.exist(database, table)
1251
+ and self.engine.schema.exist(database, table)
1252
1252
  ):
1253
1253
  continue
1254
1254
 
@@ -1260,7 +1260,7 @@ class DatabaseBuild(DatabaseBuildSuper['rdb.Database']):
1260
1260
  self.input_confirm_build(sql)
1261
1261
 
1262
1262
  ## Execute.
1263
- self.db.execute(sql)
1263
+ self.engine.execute(sql)
1264
1264
 
1265
1265
  ## Report.
1266
1266
  text = f"View '{table}' of database '{database}' build completed."
@@ -1270,7 +1270,7 @@ class DatabaseBuild(DatabaseBuildSuper['rdb.Database']):
1270
1270
  __call__ = build
1271
1271
 
1272
1272
 
1273
- class DatabaseBuildAsync(DatabaseBuildSuper['rdb.DatabaseAsync']):
1273
+ class DatabaseBuildAsync(DatabaseBuildSuper['rengine.DatabaseEngineAsync']):
1274
1274
  """
1275
1275
  Asynchronous database build type.
1276
1276
  """
@@ -1291,7 +1291,7 @@ class DatabaseBuildAsync(DatabaseBuildSuper['rdb.DatabaseAsync']):
1291
1291
  """
1292
1292
 
1293
1293
  # Create.
1294
- await self.db.orm.create(*models, skip=skip)
1294
+ await self.engine.orm.create(*models, skip=skip)
1295
1295
 
1296
1296
 
1297
1297
  async def drop_orm_table(
@@ -1309,7 +1309,7 @@ class DatabaseBuildAsync(DatabaseBuildSuper['rdb.DatabaseAsync']):
1309
1309
  """
1310
1310
 
1311
1311
  # Drop.
1312
- await self.db.orm.drop(*models, skip=skip)
1312
+ await self.engine.orm.drop(*models, skip=skip)
1313
1313
 
1314
1314
 
1315
1315
  async def build(
@@ -1350,7 +1350,7 @@ class DatabaseBuildAsync(DatabaseBuildSuper['rdb.DatabaseAsync']):
1350
1350
  ## Exist.
1351
1351
  if (
1352
1352
  skip
1353
- and await self.db.schema.exist(database)
1353
+ and await self.engine.schema.exist(database)
1354
1354
  ):
1355
1355
  continue
1356
1356
 
@@ -1362,7 +1362,7 @@ class DatabaseBuildAsync(DatabaseBuildSuper['rdb.DatabaseAsync']):
1362
1362
  self.input_confirm_build(sql)
1363
1363
 
1364
1364
  ## Execute.
1365
- await self.db.execute(sql)
1365
+ await self.engine.execute(sql)
1366
1366
 
1367
1367
  ## Report.
1368
1368
  text = f"Database '{database}' build completed."
@@ -1377,13 +1377,13 @@ class DatabaseBuildAsync(DatabaseBuildSuper['rdb.DatabaseAsync']):
1377
1377
  and isinstance(params, DatabaseORMModel)
1378
1378
  or issubclass(params, DatabaseORMModel)
1379
1379
  ):
1380
- database = self.db.database
1380
+ database = self.engine.database
1381
1381
  table = params._get_table().name
1382
1382
 
1383
1383
  ## Exist.
1384
1384
  if (
1385
1385
  skip
1386
- and await self.db.schema.exist(self.db.database, table)
1386
+ and await self.engine.schema.exist(self.engine.database, table)
1387
1387
  ):
1388
1388
  continue
1389
1389
 
@@ -1399,14 +1399,14 @@ class DatabaseBuildAsync(DatabaseBuildSuper['rdb.DatabaseAsync']):
1399
1399
  else:
1400
1400
  path: str | tuple[str, str] = params['path']
1401
1401
  if type(path) == str:
1402
- database, table = self.db.database, path
1402
+ database, table = self.engine.database, path
1403
1403
  else:
1404
1404
  database, table = path
1405
1405
 
1406
1406
  ### Exist.
1407
1407
  if (
1408
1408
  skip
1409
- and await self.db.schema.exist(database, table)
1409
+ and await self.engine.schema.exist(database, table)
1410
1410
  ):
1411
1411
  continue
1412
1412
 
@@ -1418,7 +1418,7 @@ class DatabaseBuildAsync(DatabaseBuildSuper['rdb.DatabaseAsync']):
1418
1418
  self.input_confirm_build(sql)
1419
1419
 
1420
1420
  ### Execute.
1421
- await self.db.execute(sql)
1421
+ await self.engine.execute(sql)
1422
1422
  refresh_schema = True
1423
1423
 
1424
1424
  ## Report.
@@ -1427,20 +1427,20 @@ class DatabaseBuildAsync(DatabaseBuildSuper['rdb.DatabaseAsync']):
1427
1427
 
1428
1428
  # Refresh schema.
1429
1429
  if refresh_schema:
1430
- self.db.schema()
1430
+ self.engine.schema()
1431
1431
 
1432
1432
  # View.
1433
1433
  for params in views:
1434
1434
  path = params['path']
1435
1435
  if type(path) == str:
1436
- database, table = self.db.database, path
1436
+ database, table = self.engine.database, path
1437
1437
  else:
1438
1438
  database, table = path
1439
1439
 
1440
1440
  ## Exist.
1441
1441
  if (
1442
1442
  skip
1443
- and await self.db.schema.exist(database, table)
1443
+ and await self.engine.schema.exist(database, table)
1444
1444
  ):
1445
1445
  continue
1446
1446
 
@@ -1452,7 +1452,7 @@ class DatabaseBuildAsync(DatabaseBuildSuper['rdb.DatabaseAsync']):
1452
1452
  self.input_confirm_build(sql)
1453
1453
 
1454
1454
  ## Execute.
1455
- await self.db.execute(sql)
1455
+ await self.engine.execute(sql)
1456
1456
 
1457
1457
  ## Report.
1458
1458
  text = f"View '{table}' of database '{database}' build completed."
@@ -1462,14 +1462,14 @@ class DatabaseBuildAsync(DatabaseBuildSuper['rdb.DatabaseAsync']):
1462
1462
  for params in views_stats:
1463
1463
  path = params['path']
1464
1464
  if type(path) == str:
1465
- database, table = self.db.database, path
1465
+ database, table = self.engine.database, path
1466
1466
  else:
1467
1467
  database, table = path
1468
1468
 
1469
1469
  ## Exist.
1470
1470
  if (
1471
1471
  skip
1472
- and await self.db.schema.exist(database, table)
1472
+ and await self.engine.schema.exist(database, table)
1473
1473
  ):
1474
1474
  continue
1475
1475
 
@@ -1481,7 +1481,7 @@ class DatabaseBuildAsync(DatabaseBuildSuper['rdb.DatabaseAsync']):
1481
1481
  self.input_confirm_build(sql)
1482
1482
 
1483
1483
  ## Execute.
1484
- await self.db.execute(sql)
1484
+ await self.engine.execute(sql)
1485
1485
 
1486
1486
  ## Report.
1487
1487
  text = f"View '{table}' of database '{database}' build completed."