reydb 1.1.23__py3-none-any.whl → 1.1.25__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/rbuild.py +2 -1
- reydb/rconn.py +1 -0
- reydb/rdb.py +2 -0
- reydb/rexec.py +2 -1
- reydb/rfile.py +47 -36
- reydb/rinfo.py +2 -1
- reydb/rparam.py +2 -1
- {reydb-1.1.23.dist-info → reydb-1.1.25.dist-info}/METADATA +1 -1
- reydb-1.1.25.dist-info/RECORD +14 -0
- reydb-1.1.23.dist-info/RECORD +0 -14
- {reydb-1.1.23.dist-info → reydb-1.1.25.dist-info}/WHEEL +0 -0
- {reydb-1.1.23.dist-info → reydb-1.1.25.dist-info}/licenses/LICENSE +0 -0
reydb/rbuild.py
CHANGED
reydb/rconn.py
CHANGED
reydb/rdb.py
CHANGED
@@ -753,6 +753,7 @@ class Database(BaseDatabase):
|
|
753
753
|
syntax = [
|
754
754
|
search('[a-zA-Z]+', sql_part).upper()
|
755
755
|
for sql_part in sql.split(';')
|
756
|
+
if sql_part != ''
|
756
757
|
]
|
757
758
|
|
758
759
|
return syntax
|
@@ -819,6 +820,7 @@ class Database(BaseDatabase):
|
|
819
820
|
sqls = [
|
820
821
|
sql_part.strip()
|
821
822
|
for sql_part in sql.text.split(';')
|
823
|
+
if sql_part != ''
|
822
824
|
]
|
823
825
|
if data == []:
|
824
826
|
echo(report_info, *sqls, title='SQL')
|
reydb/rexec.py
CHANGED
reydb/rfile.py
CHANGED
@@ -15,7 +15,8 @@ from reykit.rbase import throw
|
|
15
15
|
from reykit.ros import File, Folder, get_md5
|
16
16
|
|
17
17
|
from .rbase import BaseDatabase
|
18
|
-
from .rconn import
|
18
|
+
from .rconn import DBConnection
|
19
|
+
from .rdb import Database
|
19
20
|
|
20
21
|
|
21
22
|
__all__ = (
|
@@ -29,41 +30,43 @@ FileInfo = TypedDict('FileInfo', {'create_time': datetime, 'md5': str, 'name': s
|
|
29
30
|
class DBFile(BaseDatabase):
|
30
31
|
"""
|
31
32
|
Database file type.
|
33
|
+
Can create database used `self.build` method.
|
32
34
|
"""
|
33
35
|
|
34
36
|
|
35
37
|
def __init__(
|
36
38
|
self,
|
37
|
-
|
39
|
+
database: Database | DBConnection
|
38
40
|
) -> None:
|
39
41
|
"""
|
40
42
|
Build instance attributes.
|
41
43
|
|
42
44
|
Parameters
|
43
45
|
----------
|
44
|
-
|
46
|
+
database : Database or DBConnection instance.
|
45
47
|
"""
|
46
48
|
|
47
49
|
# SQLite.
|
48
|
-
if
|
50
|
+
if database.backend == 'sqlite':
|
49
51
|
text='not suitable for SQLite databases'
|
50
52
|
throw(AssertionError, text=text)
|
51
53
|
|
52
54
|
# Set attribute.
|
53
|
-
self.
|
55
|
+
self.database = database
|
54
56
|
|
55
57
|
## Database path name.
|
56
|
-
self.
|
58
|
+
self.db_names = {
|
57
59
|
'file': 'file',
|
58
60
|
'file.information': 'information',
|
59
61
|
'file.data': 'data',
|
60
|
-
'file.stats': 'stats'
|
62
|
+
'file.stats': 'stats',
|
63
|
+
'file.data_information': 'data_information'
|
61
64
|
}
|
62
65
|
|
63
66
|
|
64
67
|
def build(self) -> None:
|
65
68
|
"""
|
66
|
-
Check and build all standard databases and tables, by `self.
|
69
|
+
Check and build all standard databases and tables, by `self.db_names`.
|
67
70
|
"""
|
68
71
|
|
69
72
|
# Set parameter.
|
@@ -71,7 +74,7 @@ class DBFile(BaseDatabase):
|
|
71
74
|
## Database.
|
72
75
|
databases = [
|
73
76
|
{
|
74
|
-
'name': self.
|
77
|
+
'name': self.db_names['file']
|
75
78
|
}
|
76
79
|
]
|
77
80
|
|
@@ -80,7 +83,7 @@ class DBFile(BaseDatabase):
|
|
80
83
|
|
81
84
|
### 'information'.
|
82
85
|
{
|
83
|
-
'path': (self.
|
86
|
+
'path': (self.db_names['file'], self.db_names['file.information']),
|
84
87
|
'fields': [
|
85
88
|
{
|
86
89
|
'name': 'create_time',
|
@@ -92,7 +95,7 @@ class DBFile(BaseDatabase):
|
|
92
95
|
'name': 'file_id',
|
93
96
|
'type': 'mediumint unsigned',
|
94
97
|
'constraint': 'NOT NULL AUTO_INCREMENT',
|
95
|
-
'comment': 'File
|
98
|
+
'comment': 'File ID.'
|
96
99
|
},
|
97
100
|
{
|
98
101
|
'name': 'md5',
|
@@ -133,7 +136,7 @@ class DBFile(BaseDatabase):
|
|
133
136
|
|
134
137
|
### 'data'.
|
135
138
|
{
|
136
|
-
'path': (self.
|
139
|
+
'path': (self.db_names['file'], self.db_names['file.data']),
|
137
140
|
'fields': [
|
138
141
|
{
|
139
142
|
'name': 'md5',
|
@@ -165,17 +168,17 @@ class DBFile(BaseDatabase):
|
|
165
168
|
|
166
169
|
### Data information.
|
167
170
|
{
|
168
|
-
'path': ('file', 'data_information'),
|
171
|
+
'path': (self.db_names['file'], self.db_names['file.data_information']),
|
169
172
|
'select': (
|
170
173
|
'SELECT `b`.`last_time`, `a`.`md5`, `a`.`size`, `b`.`names`, `b`.`notes`\n'
|
171
|
-
'FROM `file`.`data` AS `a`\n'
|
174
|
+
f'FROM `{self.db_names['file']}`.`{self.db_names['file.data']}` AS `a`\n'
|
172
175
|
'LEFT JOIN (\n'
|
173
176
|
' SELECT\n'
|
174
177
|
' `md5`,\n'
|
175
178
|
" GROUP_CONCAT(DISTINCT(`name`) ORDER BY `create_time` DESC SEPARATOR ' | ') AS `names`,\n"
|
176
179
|
" GROUP_CONCAT(DISTINCT(`note`) ORDER BY `create_time` DESC SEPARATOR ' | ') AS `notes`,\n"
|
177
180
|
' MAX(`create_time`) as `last_time`\n'
|
178
|
-
' FROM `file`.`information`\n'
|
181
|
+
f' FROM `{self.db_names['file']}`.`{self.db_names['file.information']}`\n'
|
179
182
|
' GROUP BY `md5`\n'
|
180
183
|
' ORDER BY `last_time` DESC\n'
|
181
184
|
') AS `b`\n'
|
@@ -191,13 +194,13 @@ class DBFile(BaseDatabase):
|
|
191
194
|
|
192
195
|
### 'stats'.
|
193
196
|
{
|
194
|
-
'path': (self.
|
197
|
+
'path': (self.db_names['file'], self.db_names['file.stats']),
|
195
198
|
'items': [
|
196
199
|
{
|
197
200
|
'name': 'count',
|
198
201
|
'select': (
|
199
202
|
'SELECT COUNT(1)\n'
|
200
|
-
f'FROM `{self.
|
203
|
+
f'FROM `{self.db_names['file']}`.`{self.db_names['file.information']}`'
|
201
204
|
),
|
202
205
|
'comment': 'File information count.'
|
203
206
|
},
|
@@ -205,10 +208,21 @@ class DBFile(BaseDatabase):
|
|
205
208
|
'name': 'count_data',
|
206
209
|
'select': (
|
207
210
|
'SELECT COUNT(1)\n'
|
208
|
-
f'FROM `{self.
|
211
|
+
f'FROM `{self.db_names['file']}`.`{self.db_names['file.data']}`'
|
209
212
|
),
|
210
213
|
'comment': 'File data unique count.'
|
211
214
|
},
|
215
|
+
{
|
216
|
+
'name': 'size_sum',
|
217
|
+
'select': (
|
218
|
+
'SELECT CONCAT(\n'
|
219
|
+
' ROUND(SUM(`size`) / 1024),\n'
|
220
|
+
" ' KB'\n"
|
221
|
+
')\n'
|
222
|
+
f'FROM `{self.db_names['file']}`.`{self.db_names['file.data']}`'
|
223
|
+
),
|
224
|
+
'comment': 'File total size.'
|
225
|
+
},
|
212
226
|
{
|
213
227
|
'name': 'size_avg',
|
214
228
|
'select': (
|
@@ -216,7 +230,7 @@ class DBFile(BaseDatabase):
|
|
216
230
|
' ROUND(AVG(`size`) / 1024),\n'
|
217
231
|
" ' KB'\n"
|
218
232
|
')\n'
|
219
|
-
f'FROM `{self.
|
233
|
+
f'FROM `{self.db_names['file']}`.`{self.db_names['file.data']}`'
|
220
234
|
),
|
221
235
|
'comment': 'File average size.'
|
222
236
|
},
|
@@ -227,7 +241,7 @@ class DBFile(BaseDatabase):
|
|
227
241
|
' ROUND(MAX(`size`) / 1024),\n'
|
228
242
|
" ' KB'\n"
|
229
243
|
')\n'
|
230
|
-
f'FROM `{self.
|
244
|
+
f'FROM `{self.db_names['file']}`.`{self.db_names['file.data']}`'
|
231
245
|
),
|
232
246
|
'comment': 'File maximum size.'
|
233
247
|
},
|
@@ -235,7 +249,7 @@ class DBFile(BaseDatabase):
|
|
235
249
|
'name': 'last_time',
|
236
250
|
'select': (
|
237
251
|
'SELECT MAX(`create_time`)\n'
|
238
|
-
f'FROM `{self.
|
252
|
+
f'FROM `{self.db_names['file']}`.`{self.db_names['file.information']}`'
|
239
253
|
),
|
240
254
|
'comment': 'File last record create time.'
|
241
255
|
}
|
@@ -245,7 +259,7 @@ class DBFile(BaseDatabase):
|
|
245
259
|
]
|
246
260
|
|
247
261
|
# Build.
|
248
|
-
self.
|
262
|
+
self.database.build.build(databases, tables, views, views_stats)
|
249
263
|
|
250
264
|
|
251
265
|
def upload(
|
@@ -273,7 +287,7 @@ class DBFile(BaseDatabase):
|
|
273
287
|
"""
|
274
288
|
|
275
289
|
# Handle parameter.
|
276
|
-
conn = self.
|
290
|
+
conn = self.database.connect()
|
277
291
|
match source:
|
278
292
|
|
279
293
|
## File path.
|
@@ -300,7 +314,7 @@ class DBFile(BaseDatabase):
|
|
300
314
|
|
301
315
|
# Exist.
|
302
316
|
exist = conn.execute_exist(
|
303
|
-
(self.
|
317
|
+
(self.db_names['file'], self.db_names['file.data']),
|
304
318
|
'`md5` = :file_md5',
|
305
319
|
file_md5=file_md5
|
306
320
|
)
|
@@ -315,7 +329,7 @@ class DBFile(BaseDatabase):
|
|
315
329
|
'bytes': file_bytes
|
316
330
|
}
|
317
331
|
conn.execute_insert(
|
318
|
-
(self.
|
332
|
+
(self.db_names['file'], self.db_names['file.data']),
|
319
333
|
data,
|
320
334
|
'ignore'
|
321
335
|
)
|
@@ -327,7 +341,7 @@ class DBFile(BaseDatabase):
|
|
327
341
|
'note': note
|
328
342
|
}
|
329
343
|
conn.execute_insert(
|
330
|
-
(self.
|
344
|
+
(self.db_names['file'], self.db_names['file.information']),
|
331
345
|
data
|
332
346
|
)
|
333
347
|
|
@@ -380,17 +394,17 @@ class DBFile(BaseDatabase):
|
|
380
394
|
sql = (
|
381
395
|
'SELECT `name`, (\n'
|
382
396
|
' SELECT `bytes`\n'
|
383
|
-
f' FROM `{self.
|
384
|
-
f' WHERE `md5` = `{self.
|
397
|
+
f' FROM `{self.db_names['file']}`.`{self.db_names['file.data']}`\n'
|
398
|
+
f' WHERE `md5` = `{self.db_names['file.information']}`.`md5`\n'
|
385
399
|
' LIMIT 1\n'
|
386
400
|
') AS `bytes`\n'
|
387
|
-
f'FROM `{self.
|
401
|
+
f'FROM `{self.db_names['file']}`.`{self.db_names['file.information']}`\n'
|
388
402
|
'WHERE `file_id` = :file_id\n'
|
389
403
|
'LIMIT 1'
|
390
404
|
)
|
391
405
|
|
392
406
|
# Execute SQL.
|
393
|
-
result = self.
|
407
|
+
result = self.database.execute(sql, file_id=file_id)
|
394
408
|
|
395
409
|
# Check.
|
396
410
|
if result.empty:
|
@@ -432,17 +446,17 @@ class DBFile(BaseDatabase):
|
|
432
446
|
sql = (
|
433
447
|
'SELECT `create_time`, `md5`, `name`, `note`, (\n'
|
434
448
|
' SELECT `size`\n'
|
435
|
-
f' FROM `{self.
|
449
|
+
f' FROM `{self.db_names['file']}`.`{self.db_names['file.data']}`\n'
|
436
450
|
' WHERE `md5` = `a`.`md5`\n'
|
437
451
|
' LIMIT 1\n'
|
438
452
|
') AS `size`\n'
|
439
|
-
f'FROM `{self.
|
453
|
+
f'FROM `{self.db_names['file']}`.`{self.db_names['file.information']}` AS `a`\n'
|
440
454
|
'WHERE `file_id` = :file_id\n'
|
441
455
|
'LIMIT 1'
|
442
456
|
)
|
443
457
|
|
444
458
|
# Execute SQL.
|
445
|
-
result = self.
|
459
|
+
result = self.database.execute(sql, file_id=file_id)
|
446
460
|
|
447
461
|
# Check.
|
448
462
|
if result.empty:
|
@@ -453,6 +467,3 @@ class DBFile(BaseDatabase):
|
|
453
467
|
info = table[0]
|
454
468
|
|
455
469
|
return info
|
456
|
-
|
457
|
-
|
458
|
-
__call__ = build
|
reydb/rinfo.py
CHANGED
reydb/rparam.py
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
reydb/__init__.py,sha256=UetBDQylwFTWiPMKF1ZPW45A6mwYWWSYneTesl4xKBY,474
|
2
|
+
reydb/rall.py,sha256=i6-ph2cahhTTF17DjUYf6KX3DNxhEvy6iedlSeF4ibI,341
|
3
|
+
reydb/rbase.py,sha256=HMhxr7_TyzAusrv5dcc1hf3PmxGWj7m63kKcr5Ikbf4,312
|
4
|
+
reydb/rbuild.py,sha256=LiYGOMZFnZi-aVGfWpKT2aEHks4ygbEubweB0-fczfQ,32344
|
5
|
+
reydb/rconn.py,sha256=XmT4IizNYxCNi1zl88HCgHwkLcWMRWWBcDLwuvjV6aE,6542
|
6
|
+
reydb/rdb.py,sha256=aHWBjgMr4w3yTbYwo0oN21t_SVbaLanUGUYeoRgAfpc,60965
|
7
|
+
reydb/rexec.py,sha256=ezYqSxW6PvvILugnlWtq-BoxfBHAec9f2P5mgIp_heA,8910
|
8
|
+
reydb/rfile.py,sha256=qsn6Gro9quVGf6nWo2aNtBZh0gjvY_EEpx4xSgRDMG4,14292
|
9
|
+
reydb/rinfo.py,sha256=p8_nlOHWqnJCD0NRgbsxqnM2VKTDNO9jj4vwgd1HvG0,14267
|
10
|
+
reydb/rparam.py,sha256=d8Ijn86ieYlWsHjAwIjrVujynfgKtMF1E-q41wGtd9Y,6855
|
11
|
+
reydb-1.1.25.dist-info/METADATA,sha256=lmwYmLqHo0qrAW2fh7Qqh9nKO9JTRgK1w-8UGNnDAk8,1550
|
12
|
+
reydb-1.1.25.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
13
|
+
reydb-1.1.25.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
14
|
+
reydb-1.1.25.dist-info/RECORD,,
|
reydb-1.1.23.dist-info/RECORD
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
reydb/__init__.py,sha256=UetBDQylwFTWiPMKF1ZPW45A6mwYWWSYneTesl4xKBY,474
|
2
|
-
reydb/rall.py,sha256=i6-ph2cahhTTF17DjUYf6KX3DNxhEvy6iedlSeF4ibI,341
|
3
|
-
reydb/rbase.py,sha256=HMhxr7_TyzAusrv5dcc1hf3PmxGWj7m63kKcr5Ikbf4,312
|
4
|
-
reydb/rbuild.py,sha256=ppsaGWTC3S-zwQDj3keL3oF5TddORTuEpfqNElj6thU,32327
|
5
|
-
reydb/rconn.py,sha256=ZZDssqBCb1GQT61xG1N96-wYwISTIlKO1nJkgBuwBlI,6507
|
6
|
-
reydb/rdb.py,sha256=VVytmnw07MFC-gc3JzjJC50SJTXA0H-oy_pFtYf_ras,60895
|
7
|
-
reydb/rexec.py,sha256=kc5xSfuEDFW9rcAeJj_x6JWPDSYnHZQXcfSBXFGIhL8,8893
|
8
|
-
reydb/rfile.py,sha256=VUJy7edvHq-D_KyJYm5gYS338l7sqCNAcwf3InpI2So,13664
|
9
|
-
reydb/rinfo.py,sha256=NhcFhzp9gQ49EpAqcFYXcG-FMUXu3qii8WGoHxN6UcQ,14250
|
10
|
-
reydb/rparam.py,sha256=EVSz_D4wyiaj5ZKxvdDcECmpbriOUNBBFCzz4bnV6dY,6838
|
11
|
-
reydb-1.1.23.dist-info/METADATA,sha256=rOz7GTFTvbc5RskNO0ZchI27HxNhFnOL-_4HnEZk6bo,1550
|
12
|
-
reydb-1.1.23.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
13
|
-
reydb-1.1.23.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
14
|
-
reydb-1.1.23.dist-info/RECORD,,
|
File without changes
|
File without changes
|