reydb 1.1.49__py3-none-any.whl → 1.1.51__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 +1 -0
- reydb/rall.py +1 -0
- reydb/rbuild.py +24 -25
- reydb/rconfig.py +16 -13
- reydb/rconn.py +24 -25
- reydb/rdb.py +65 -44
- reydb/rerror.py +6 -7
- reydb/rexec.py +1 -1
- reydb/rfile.py +7 -9
- reydb/rinfo.py +58 -60
- reydb/rorm.py +567 -0
- reydb/rparam.py +13 -14
- {reydb-1.1.49.dist-info → reydb-1.1.51.dist-info}/METADATA +1 -1
- reydb-1.1.51.dist-info/RECORD +17 -0
- reydb-1.1.49.dist-info/RECORD +0 -16
- {reydb-1.1.49.dist-info → reydb-1.1.51.dist-info}/WHEEL +0 -0
- {reydb-1.1.49.dist-info → reydb-1.1.51.dist-info}/licenses/LICENSE +0 -0
reydb/__init__.py
CHANGED
reydb/rall.py
CHANGED
reydb/rbuild.py
CHANGED
@@ -15,7 +15,6 @@ from reykit.rbase import throw
|
|
15
15
|
from reykit.rstdout import ask
|
16
16
|
|
17
17
|
from .rbase import DatabaseBase, extract_path
|
18
|
-
from .rconn import DatabaseConnection
|
19
18
|
from .rdb import Database
|
20
19
|
|
21
20
|
|
@@ -52,17 +51,17 @@ class DatabaseBuild(DatabaseBase):
|
|
52
51
|
"""
|
53
52
|
|
54
53
|
|
55
|
-
def __init__(self,
|
54
|
+
def __init__(self, db: Database) -> None:
|
56
55
|
"""
|
57
56
|
Build instance attributes.
|
58
57
|
|
59
58
|
Parameters
|
60
59
|
----------
|
61
|
-
|
60
|
+
db: `Database` instance.
|
62
61
|
"""
|
63
62
|
|
64
63
|
# Set attribute.
|
65
|
-
self.
|
64
|
+
self.db = db
|
66
65
|
self._schema: dict[str, dict[str, list[str]]] | None = None
|
67
66
|
|
68
67
|
|
@@ -93,7 +92,7 @@ class DatabaseBuild(DatabaseBase):
|
|
93
92
|
|
94
93
|
# Execute.
|
95
94
|
if execute:
|
96
|
-
self.
|
95
|
+
self.db.execute(sql)
|
97
96
|
|
98
97
|
return sql
|
99
98
|
|
@@ -343,7 +342,7 @@ class DatabaseBuild(DatabaseBase):
|
|
343
342
|
|
344
343
|
# Execute.
|
345
344
|
if execute:
|
346
|
-
self.
|
345
|
+
self.db.execute(sql)
|
347
346
|
|
348
347
|
return sql
|
349
348
|
|
@@ -379,7 +378,7 @@ class DatabaseBuild(DatabaseBase):
|
|
379
378
|
|
380
379
|
# Execute.
|
381
380
|
if execute:
|
382
|
-
self.
|
381
|
+
self.db.execute(sql)
|
383
382
|
|
384
383
|
return sql
|
385
384
|
|
@@ -472,7 +471,7 @@ class DatabaseBuild(DatabaseBase):
|
|
472
471
|
|
473
472
|
# Execute.
|
474
473
|
if execute:
|
475
|
-
self.
|
474
|
+
self.db.execute(sql)
|
476
475
|
|
477
476
|
return sql
|
478
477
|
|
@@ -505,7 +504,7 @@ class DatabaseBuild(DatabaseBase):
|
|
505
504
|
|
506
505
|
# Execute.
|
507
506
|
if execute:
|
508
|
-
self.
|
507
|
+
self.db.execute(sql)
|
509
508
|
|
510
509
|
return sql
|
511
510
|
|
@@ -538,7 +537,7 @@ class DatabaseBuild(DatabaseBase):
|
|
538
537
|
|
539
538
|
# Execute.
|
540
539
|
if execute:
|
541
|
-
self.
|
540
|
+
self.db.execute(sql)
|
542
541
|
|
543
542
|
return sql
|
544
543
|
|
@@ -588,7 +587,7 @@ class DatabaseBuild(DatabaseBase):
|
|
588
587
|
|
589
588
|
# Execute.
|
590
589
|
if execute:
|
591
|
-
self.
|
590
|
+
self.db.execute(sql)
|
592
591
|
|
593
592
|
return sql
|
594
593
|
|
@@ -703,7 +702,7 @@ class DatabaseBuild(DatabaseBase):
|
|
703
702
|
|
704
703
|
# Execute.
|
705
704
|
if execute:
|
706
|
-
self.
|
705
|
+
self.db.execute(sql)
|
707
706
|
|
708
707
|
return sql
|
709
708
|
|
@@ -774,7 +773,7 @@ class DatabaseBuild(DatabaseBase):
|
|
774
773
|
|
775
774
|
# Execute.
|
776
775
|
if execute:
|
777
|
-
self.
|
776
|
+
self.db.execute(sql)
|
778
777
|
|
779
778
|
return sql
|
780
779
|
|
@@ -893,7 +892,7 @@ class DatabaseBuild(DatabaseBase):
|
|
893
892
|
|
894
893
|
# Execute.
|
895
894
|
if execute:
|
896
|
-
self.
|
895
|
+
self.db.execute(sql)
|
897
896
|
|
898
897
|
return sql
|
899
898
|
|
@@ -928,7 +927,7 @@ class DatabaseBuild(DatabaseBase):
|
|
928
927
|
|
929
928
|
# Execute.
|
930
929
|
if execute:
|
931
|
-
self.
|
930
|
+
self.db.execute(sql)
|
932
931
|
|
933
932
|
return sql
|
934
933
|
|
@@ -961,7 +960,7 @@ class DatabaseBuild(DatabaseBase):
|
|
961
960
|
|
962
961
|
# Execute.
|
963
962
|
if execute:
|
964
|
-
self.
|
963
|
+
self.db.execute(sql)
|
965
964
|
|
966
965
|
return sql
|
967
966
|
|
@@ -987,7 +986,7 @@ class DatabaseBuild(DatabaseBase):
|
|
987
986
|
# Handle parameter.
|
988
987
|
database, table, column = extract_path(path)
|
989
988
|
if self._schema is None:
|
990
|
-
self._schema = self.
|
989
|
+
self._schema = self.db.schema(False)
|
991
990
|
|
992
991
|
# Judge.
|
993
992
|
judge = (
|
@@ -1077,7 +1076,7 @@ class DatabaseBuild(DatabaseBase):
|
|
1077
1076
|
database = params['name']
|
1078
1077
|
|
1079
1078
|
## Exist.
|
1080
|
-
exist = self.
|
1079
|
+
exist = self.db.build.exist((database, None, None))
|
1081
1080
|
if exist:
|
1082
1081
|
continue
|
1083
1082
|
|
@@ -1088,7 +1087,7 @@ class DatabaseBuild(DatabaseBase):
|
|
1088
1087
|
self.input_confirm_build(sql)
|
1089
1088
|
|
1090
1089
|
## Execute.
|
1091
|
-
self.
|
1090
|
+
self.db.execute(sql)
|
1092
1091
|
|
1093
1092
|
## Report.
|
1094
1093
|
text = f"Database '{database}' build completed."
|
@@ -1100,7 +1099,7 @@ class DatabaseBuild(DatabaseBase):
|
|
1100
1099
|
database, table, _ = extract_path(path)
|
1101
1100
|
|
1102
1101
|
## Exist.
|
1103
|
-
exist = self.
|
1102
|
+
exist = self.db.build.exist((database, table, None))
|
1104
1103
|
if exist:
|
1105
1104
|
continue
|
1106
1105
|
|
@@ -1111,7 +1110,7 @@ class DatabaseBuild(DatabaseBase):
|
|
1111
1110
|
self.input_confirm_build(sql)
|
1112
1111
|
|
1113
1112
|
## Execute.
|
1114
|
-
self.
|
1113
|
+
self.db.execute(sql)
|
1115
1114
|
|
1116
1115
|
## Report.
|
1117
1116
|
text = f"Table '{table}' of database '{database}' build completed."
|
@@ -1123,7 +1122,7 @@ class DatabaseBuild(DatabaseBase):
|
|
1123
1122
|
database, view, _ = extract_path(path)
|
1124
1123
|
|
1125
1124
|
## Exist.
|
1126
|
-
exist = self.
|
1125
|
+
exist = self.db.build.exist((database, view, None))
|
1127
1126
|
if exist:
|
1128
1127
|
continue
|
1129
1128
|
|
@@ -1134,7 +1133,7 @@ class DatabaseBuild(DatabaseBase):
|
|
1134
1133
|
self.input_confirm_build(sql)
|
1135
1134
|
|
1136
1135
|
## Execute.
|
1137
|
-
self.
|
1136
|
+
self.db.execute(sql)
|
1138
1137
|
|
1139
1138
|
## Report.
|
1140
1139
|
text = f"View '{view}' of database '{database}' build completed."
|
@@ -1146,7 +1145,7 @@ class DatabaseBuild(DatabaseBase):
|
|
1146
1145
|
database, view, _ = extract_path(path)
|
1147
1146
|
|
1148
1147
|
## Exist.
|
1149
|
-
exist = self.
|
1148
|
+
exist = self.db.build.exist((database, view, None))
|
1150
1149
|
if exist:
|
1151
1150
|
continue
|
1152
1151
|
|
@@ -1157,7 +1156,7 @@ class DatabaseBuild(DatabaseBase):
|
|
1157
1156
|
self.input_confirm_build(sql)
|
1158
1157
|
|
1159
1158
|
## Execute.
|
1160
|
-
self.
|
1159
|
+
self.db.execute(sql)
|
1161
1160
|
|
1162
1161
|
## Report.
|
1163
1162
|
text = f"View '{view}' of database '{database}' build completed."
|
reydb/rconfig.py
CHANGED
@@ -19,7 +19,6 @@ from datetime import (
|
|
19
19
|
)
|
20
20
|
from reykit.rbase import null, throw
|
21
21
|
|
22
|
-
from .rconn import DatabaseConnection
|
23
22
|
from .rdb import Database
|
24
23
|
|
25
24
|
|
@@ -49,13 +48,17 @@ class DatabaseConfig(object):
|
|
49
48
|
"""
|
50
49
|
|
51
50
|
|
52
|
-
def __init__(self,
|
51
|
+
def __init__(self, db: Database) -> None:
|
53
52
|
"""
|
54
53
|
Build instance attributes.
|
54
|
+
|
55
|
+
Parameters
|
56
|
+
----------
|
57
|
+
db: `Database` instance.
|
55
58
|
"""
|
56
59
|
|
57
60
|
# Build.
|
58
|
-
self.
|
61
|
+
self.db = db
|
59
62
|
|
60
63
|
## Database path name.
|
61
64
|
self.db_names = {
|
@@ -180,7 +183,7 @@ class DatabaseConfig(object):
|
|
180
183
|
]
|
181
184
|
|
182
185
|
# Build.
|
183
|
-
self.
|
186
|
+
self.db.build.build(databases, tables, views_stats=views_stats)
|
184
187
|
|
185
188
|
|
186
189
|
@property
|
@@ -194,7 +197,7 @@ class DatabaseConfig(object):
|
|
194
197
|
"""
|
195
198
|
|
196
199
|
# Get.
|
197
|
-
result = self.
|
200
|
+
result = self.db.execute.select(
|
198
201
|
(self.db_names['base'], self.db_names['base.config']),
|
199
202
|
['key', 'value', 'type', 'note'],
|
200
203
|
order='IFNULL(`update_time`, `create_time`) DESC'
|
@@ -230,7 +233,7 @@ class DatabaseConfig(object):
|
|
230
233
|
|
231
234
|
# Get.
|
232
235
|
where = '`key` = :key'
|
233
|
-
result = self.
|
236
|
+
result = self.db.execute.select(
|
234
237
|
(self.db_names['base'], self.db_names['base.config']),
|
235
238
|
'`value`',
|
236
239
|
where,
|
@@ -276,7 +279,7 @@ class DatabaseConfig(object):
|
|
276
279
|
'type': type(default).__name__,
|
277
280
|
'note': default_note
|
278
281
|
}
|
279
|
-
result = self.
|
282
|
+
result = self.db.execute.insert(
|
280
283
|
(self.db_names['base'], self.db_names['base.config']),
|
281
284
|
data,
|
282
285
|
'ignore'
|
@@ -317,7 +320,7 @@ class DatabaseConfig(object):
|
|
317
320
|
row['type'] = type(row['value']).__name__
|
318
321
|
|
319
322
|
# Update.
|
320
|
-
self.
|
323
|
+
self.db.execute.insert(
|
321
324
|
(self.db_names['base'], self.db_names['base.config']),
|
322
325
|
data,
|
323
326
|
'update'
|
@@ -340,7 +343,7 @@ class DatabaseConfig(object):
|
|
340
343
|
else:
|
341
344
|
where = '`key` in :key'
|
342
345
|
limit = None
|
343
|
-
result = self.
|
346
|
+
result = self.db.execute.delete(
|
344
347
|
(self.db_names['base'], self.db_names['base.config']),
|
345
348
|
where,
|
346
349
|
limit=limit,
|
@@ -362,7 +365,7 @@ class DatabaseConfig(object):
|
|
362
365
|
"""
|
363
366
|
|
364
367
|
# Get.
|
365
|
-
result = self.
|
368
|
+
result = self.db.execute.select(
|
366
369
|
(self.db_names['base'], self.db_names['base.config']),
|
367
370
|
['key', 'value']
|
368
371
|
)
|
@@ -388,7 +391,7 @@ class DatabaseConfig(object):
|
|
388
391
|
"""
|
389
392
|
|
390
393
|
# Get.
|
391
|
-
result = self.
|
394
|
+
result = self.db.execute.select(
|
392
395
|
(self.db_names['base'], self.db_names['base.config']),
|
393
396
|
'`key`'
|
394
397
|
)
|
@@ -413,7 +416,7 @@ class DatabaseConfig(object):
|
|
413
416
|
"""
|
414
417
|
|
415
418
|
# Get.
|
416
|
-
result = self.
|
419
|
+
result = self.db.execute.select(
|
417
420
|
(self.db_names['base'], self.db_names['base.config']),
|
418
421
|
'`value`'
|
419
422
|
)
|
@@ -475,7 +478,7 @@ class DatabaseConfig(object):
|
|
475
478
|
'type': type(value).__name__,
|
476
479
|
'note': note
|
477
480
|
}
|
478
|
-
self.
|
481
|
+
self.db.execute.insert(
|
479
482
|
(self.db_names['base'], self.db_names['base.config']),
|
480
483
|
data,
|
481
484
|
'update'
|
reydb/rconn.py
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
from typing import Self
|
13
|
+
from sqlalchemy import Transaction
|
13
14
|
|
14
15
|
from .rbase import DatabaseBase
|
15
16
|
from .rdb import Database
|
@@ -36,38 +37,19 @@ class DatabaseConnection(DatabaseBase):
|
|
36
37
|
|
37
38
|
Parameters
|
38
39
|
----------
|
39
|
-
db : Database instance.
|
40
|
+
db : `Database` instance.
|
40
41
|
autocommit: Whether automatic commit connection.
|
41
42
|
"""
|
42
43
|
|
43
|
-
# Build.
|
44
|
-
self.db = db
|
45
|
-
self.autocommit = autocommit
|
46
|
-
self.conn = db.engine.connect()
|
47
|
-
self.begin = None
|
48
|
-
|
49
|
-
|
50
|
-
@property
|
51
|
-
def execute(self):
|
52
|
-
"""
|
53
|
-
Build `database execute` instance.
|
54
|
-
|
55
|
-
Returns
|
56
|
-
-------
|
57
|
-
Instance.
|
58
|
-
"""
|
59
|
-
|
60
44
|
# Import.
|
61
45
|
from .rexec import DatabaseExecute
|
62
46
|
|
63
|
-
# Create transaction.
|
64
|
-
if self.begin is None:
|
65
|
-
self.begin = self.conn.begin()
|
66
|
-
|
67
47
|
# Build.
|
68
|
-
|
69
|
-
|
70
|
-
|
48
|
+
self.db = db
|
49
|
+
self.autocommit = autocommit
|
50
|
+
self.conn = db.engine.connect()
|
51
|
+
self.exec = DatabaseExecute(self)
|
52
|
+
self.begin: Transaction | None = None
|
71
53
|
|
72
54
|
|
73
55
|
def commit(self) -> None:
|
@@ -138,6 +120,23 @@ class DatabaseConnection(DatabaseBase):
|
|
138
120
|
__del__ = close
|
139
121
|
|
140
122
|
|
123
|
+
@property
|
124
|
+
def execute(self):
|
125
|
+
"""
|
126
|
+
Build `database execute` instance.
|
127
|
+
|
128
|
+
Returns
|
129
|
+
-------
|
130
|
+
Instance.
|
131
|
+
"""
|
132
|
+
|
133
|
+
# Create transaction.
|
134
|
+
if self.begin is None:
|
135
|
+
self.begin = self.conn.begin()
|
136
|
+
|
137
|
+
return self.exec
|
138
|
+
|
139
|
+
|
141
140
|
@property
|
142
141
|
def insert_id(self) -> int:
|
143
142
|
"""
|
reydb/rdb.py
CHANGED
@@ -25,11 +25,13 @@ __all__ = (
|
|
25
25
|
|
26
26
|
class Database(DatabaseBase):
|
27
27
|
"""
|
28
|
-
Database type
|
29
|
-
|
28
|
+
Database type, based `MySQL`.
|
29
|
+
|
30
|
+
Attributes
|
31
|
+
----------
|
32
|
+
default_report : Whether default to report execution.
|
30
33
|
"""
|
31
34
|
|
32
|
-
# Whether default to report execution.
|
33
35
|
default_report: bool = False
|
34
36
|
|
35
37
|
|
@@ -206,45 +208,6 @@ class Database(DatabaseBase):
|
|
206
208
|
return keep_n, overflow_n
|
207
209
|
|
208
210
|
|
209
|
-
def connect(self, autocommit: bool = False):
|
210
|
-
"""
|
211
|
-
Build `DatabaseConnection` instance.
|
212
|
-
|
213
|
-
Parameters
|
214
|
-
----------
|
215
|
-
autocommit: Whether automatic commit connection.
|
216
|
-
|
217
|
-
Returns
|
218
|
-
-------
|
219
|
-
Database connection instance.
|
220
|
-
"""
|
221
|
-
|
222
|
-
# Import.
|
223
|
-
from .rconn import DatabaseConnection
|
224
|
-
|
225
|
-
# Build.
|
226
|
-
conn = DatabaseConnection(self, autocommit)
|
227
|
-
|
228
|
-
return conn
|
229
|
-
|
230
|
-
|
231
|
-
@property
|
232
|
-
def execute(self):
|
233
|
-
"""
|
234
|
-
Build `database execute` instance.
|
235
|
-
|
236
|
-
Returns
|
237
|
-
-------
|
238
|
-
Instance.
|
239
|
-
"""
|
240
|
-
|
241
|
-
# Build.
|
242
|
-
dbconn = self.connect(True)
|
243
|
-
exec = dbconn.execute
|
244
|
-
|
245
|
-
return exec
|
246
|
-
|
247
|
-
|
248
211
|
def schema(self, filter_default: bool = True) -> dict[str, dict[str, list[str]]]:
|
249
212
|
"""
|
250
213
|
Get schemata of databases and tables and columns.
|
@@ -309,12 +272,70 @@ class Database(DatabaseBase):
|
|
309
272
|
column_list.append(column)
|
310
273
|
|
311
274
|
## Add empty database.
|
312
|
-
for
|
313
|
-
schema_dict[
|
275
|
+
for name in database_names:
|
276
|
+
schema_dict[name] = None
|
314
277
|
|
315
278
|
return schema_dict
|
316
279
|
|
317
280
|
|
281
|
+
def connect(self, autocommit: bool = False):
|
282
|
+
"""
|
283
|
+
Build `DatabaseConnection` instance.
|
284
|
+
|
285
|
+
Parameters
|
286
|
+
----------
|
287
|
+
autocommit: Whether automatic commit connection.
|
288
|
+
|
289
|
+
Returns
|
290
|
+
-------
|
291
|
+
Database connection instance.
|
292
|
+
"""
|
293
|
+
|
294
|
+
# Import.
|
295
|
+
from .rconn import DatabaseConnection
|
296
|
+
|
297
|
+
# Build.
|
298
|
+
conn = DatabaseConnection(self, autocommit)
|
299
|
+
|
300
|
+
return conn
|
301
|
+
|
302
|
+
|
303
|
+
@property
|
304
|
+
def execute(self):
|
305
|
+
"""
|
306
|
+
Build `DatabaseExecute` instance.
|
307
|
+
|
308
|
+
Returns
|
309
|
+
-------
|
310
|
+
Instance.
|
311
|
+
"""
|
312
|
+
|
313
|
+
# Build.
|
314
|
+
dbconn = self.connect(True)
|
315
|
+
exec = dbconn.execute
|
316
|
+
|
317
|
+
return exec
|
318
|
+
|
319
|
+
|
320
|
+
@property
|
321
|
+
def orm(self):
|
322
|
+
"""
|
323
|
+
Build `DatabaseORM` instance.
|
324
|
+
|
325
|
+
Returns
|
326
|
+
-------
|
327
|
+
Instance.
|
328
|
+
"""
|
329
|
+
|
330
|
+
# Import.
|
331
|
+
from .rorm import DatabaseORM
|
332
|
+
|
333
|
+
# Build.
|
334
|
+
orm = DatabaseORM(self)
|
335
|
+
|
336
|
+
return orm
|
337
|
+
|
338
|
+
|
318
339
|
@property
|
319
340
|
def info(self):
|
320
341
|
"""
|
reydb/rerror.py
CHANGED
@@ -13,10 +13,9 @@ from typing import Any
|
|
13
13
|
from collections.abc import Callable
|
14
14
|
from traceback import StackSummary
|
15
15
|
from functools import wraps as functools_wraps
|
16
|
-
from reykit.rbase import T, Exit,
|
16
|
+
from reykit.rbase import T, Exit, catch_exc
|
17
17
|
|
18
18
|
from .rbase import DatabaseBase
|
19
|
-
from .rconn import DatabaseConnection
|
20
19
|
from .rdb import Database
|
21
20
|
|
22
21
|
|
@@ -32,17 +31,17 @@ class DatabaseError(DatabaseBase):
|
|
32
31
|
"""
|
33
32
|
|
34
33
|
|
35
|
-
def __init__(self,
|
34
|
+
def __init__(self, db: Database) -> None:
|
36
35
|
"""
|
37
36
|
Build instance attributes.
|
38
37
|
|
39
38
|
Parameters
|
40
39
|
----------
|
41
|
-
|
40
|
+
db: `Database` instance.
|
42
41
|
"""
|
43
42
|
|
44
43
|
# Build.
|
45
|
-
self.
|
44
|
+
self.db = db
|
46
45
|
|
47
46
|
## Database path name.
|
48
47
|
self.db_names = {
|
@@ -184,7 +183,7 @@ class DatabaseError(DatabaseBase):
|
|
184
183
|
]
|
185
184
|
|
186
185
|
# Build.
|
187
|
-
self.
|
186
|
+
self.db.build.build(databases, tables, views_stats=views_stats)
|
188
187
|
|
189
188
|
|
190
189
|
def record(
|
@@ -223,7 +222,7 @@ class DatabaseError(DatabaseBase):
|
|
223
222
|
}
|
224
223
|
|
225
224
|
# Insert.
|
226
|
-
self.
|
225
|
+
self.db.execute.insert(
|
227
226
|
(self.db_names['base'], self.db_names['base.error']),
|
228
227
|
data=data
|
229
228
|
)
|
reydb/rexec.py
CHANGED
reydb/rfile.py
CHANGED
@@ -11,11 +11,9 @@
|
|
11
11
|
|
12
12
|
from typing import TypedDict, overload
|
13
13
|
from datetime import datetime
|
14
|
-
from reykit.rbase import throw
|
15
14
|
from reykit.ros import File, Folder, get_md5
|
16
15
|
|
17
16
|
from .rbase import DatabaseBase
|
18
|
-
from .rconn import DatabaseConnection
|
19
17
|
from .rdb import Database
|
20
18
|
|
21
19
|
|
@@ -34,17 +32,17 @@ class DatabaseFile(DatabaseBase):
|
|
34
32
|
"""
|
35
33
|
|
36
34
|
|
37
|
-
def __init__(self,
|
35
|
+
def __init__(self, db: Database) -> None:
|
38
36
|
"""
|
39
37
|
Build instance attributes.
|
40
38
|
|
41
39
|
Parameters
|
42
40
|
----------
|
43
|
-
|
41
|
+
db: `Database` instance.
|
44
42
|
"""
|
45
43
|
|
46
44
|
# Build.
|
47
|
-
self.
|
45
|
+
self.db = db
|
48
46
|
|
49
47
|
## Database path name.
|
50
48
|
self.db_names = {
|
@@ -274,7 +272,7 @@ class DatabaseFile(DatabaseBase):
|
|
274
272
|
]
|
275
273
|
|
276
274
|
# Build.
|
277
|
-
self.
|
275
|
+
self.db.build.build(databases, tables, views, views_stats)
|
278
276
|
|
279
277
|
|
280
278
|
def upload(
|
@@ -302,7 +300,7 @@ class DatabaseFile(DatabaseBase):
|
|
302
300
|
"""
|
303
301
|
|
304
302
|
# Handle parameter.
|
305
|
-
conn = self.
|
303
|
+
conn = self.db.connect()
|
306
304
|
match source:
|
307
305
|
|
308
306
|
## File path.
|
@@ -419,7 +417,7 @@ class DatabaseFile(DatabaseBase):
|
|
419
417
|
)
|
420
418
|
|
421
419
|
# Execute SQL.
|
422
|
-
result = self.
|
420
|
+
result = self.db.execute(sql, file_id=file_id)
|
423
421
|
|
424
422
|
# Check.
|
425
423
|
if result.empty:
|
@@ -471,7 +469,7 @@ class DatabaseFile(DatabaseBase):
|
|
471
469
|
)
|
472
470
|
|
473
471
|
# Execute SQL.
|
474
|
-
result = self.
|
472
|
+
result = self.db.execute(sql, file_id=file_id)
|
475
473
|
|
476
474
|
# Check.
|
477
475
|
if result.empty:
|