reydb 1.1.22__py3-none-any.whl → 1.1.23__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/rconn.py +2 -5
- reydb/rdb.py +34 -10
- reydb/rfile.py +39 -11
- {reydb-1.1.22.dist-info → reydb-1.1.23.dist-info}/METADATA +1 -1
- {reydb-1.1.22.dist-info → reydb-1.1.23.dist-info}/RECORD +7 -7
- {reydb-1.1.22.dist-info → reydb-1.1.23.dist-info}/WHEEL +0 -0
- {reydb-1.1.22.dist-info → reydb-1.1.23.dist-info}/licenses/LICENSE +0 -0
reydb/rconn.py
CHANGED
@@ -149,12 +149,11 @@ class DBConnection(Database):
|
|
149
149
|
Result object.
|
150
150
|
"""
|
151
151
|
|
152
|
-
# Handle parameter
|
152
|
+
# Handle parameter by priority.
|
153
153
|
report = get_first_notnone(report, self.default_report)
|
154
154
|
|
155
155
|
# Handle parameter.
|
156
|
-
|
157
|
-
sql = sqlalchemy_text(sql)
|
156
|
+
sql = self.handle_sql(sql)
|
158
157
|
if data is None:
|
159
158
|
if kwdata == {}:
|
160
159
|
data = []
|
@@ -165,8 +164,6 @@ class DBConnection(Database):
|
|
165
164
|
data = data_table.to_table()
|
166
165
|
for row in data:
|
167
166
|
row.update(kwdata)
|
168
|
-
|
169
|
-
# Handle data.
|
170
167
|
data = self.handle_data(data, sql)
|
171
168
|
|
172
169
|
# Execute.
|
reydb/rdb.py
CHANGED
@@ -646,6 +646,32 @@ class Database(BaseDatabase):
|
|
646
646
|
return keep_n, overflow_n
|
647
647
|
|
648
648
|
|
649
|
+
def handle_sql(self, sql: str | TextClause) -> TextClause:
|
650
|
+
"""
|
651
|
+
Handle SQL.
|
652
|
+
|
653
|
+
Parameters
|
654
|
+
----------
|
655
|
+
sql : SQL in method `sqlalchemy.text` format, or TextClause object.
|
656
|
+
|
657
|
+
Returns
|
658
|
+
-------
|
659
|
+
TextClause instance.
|
660
|
+
"""
|
661
|
+
|
662
|
+
# Handle parameter.
|
663
|
+
if type(sql) == TextClause:
|
664
|
+
sql = sql.text
|
665
|
+
|
666
|
+
# Handle.
|
667
|
+
sql = sql.strip()
|
668
|
+
if sql[-1] != ';':
|
669
|
+
sql += ';'
|
670
|
+
sql = sqlalchemy_text(sql)
|
671
|
+
|
672
|
+
return sql
|
673
|
+
|
674
|
+
|
649
675
|
def handle_data(
|
650
676
|
self,
|
651
677
|
data: list[dict],
|
@@ -657,7 +683,7 @@ class Database(BaseDatabase):
|
|
657
683
|
Parameters
|
658
684
|
----------
|
659
685
|
data : Data set for filling.
|
660
|
-
sql : SQL in method sqlalchemy.text format, or TextClause object.
|
686
|
+
sql : SQL in method `sqlalchemy.text` format, or TextClause object.
|
661
687
|
|
662
688
|
Returns
|
663
689
|
-------
|
@@ -830,12 +856,11 @@ class Database(BaseDatabase):
|
|
830
856
|
Result object.
|
831
857
|
"""
|
832
858
|
|
833
|
-
# Handle parameter
|
859
|
+
# Handle parameter by priority.
|
834
860
|
report = get_first_notnone(report, self.default_report)
|
835
861
|
|
836
862
|
# Handle parameter.
|
837
|
-
|
838
|
-
sql = sqlalchemy_text(sql)
|
863
|
+
sql = self.handle_sql(sql)
|
839
864
|
if data is None:
|
840
865
|
if kwdata == {}:
|
841
866
|
data = []
|
@@ -846,8 +871,6 @@ class Database(BaseDatabase):
|
|
846
871
|
data = data_table.to_table()
|
847
872
|
for row in data:
|
848
873
|
row.update(kwdata)
|
849
|
-
|
850
|
-
# Handle data.
|
851
874
|
data = self.handle_data(data, sql)
|
852
875
|
|
853
876
|
# Execute.
|
@@ -1783,7 +1806,7 @@ class Database(BaseDatabase):
|
|
1783
1806
|
)
|
1784
1807
|
if filter_default:
|
1785
1808
|
where_database = 'WHERE `SCHEMA_NAME` NOT IN :filter_db\n'
|
1786
|
-
where_column = 'WHERE `TABLE_SCHEMA` NOT IN :filter_db\n'
|
1809
|
+
where_column = ' WHERE `TABLE_SCHEMA` NOT IN :filter_db\n'
|
1787
1810
|
else:
|
1788
1811
|
where_database = where_column = ''
|
1789
1812
|
|
@@ -1793,10 +1816,11 @@ class Database(BaseDatabase):
|
|
1793
1816
|
'FROM `information_schema`.`SCHEMATA`\n'
|
1794
1817
|
f'{where_database}'
|
1795
1818
|
'UNION ALL (\n'
|
1796
|
-
'SELECT `TABLE_SCHEMA`, `TABLE_NAME`, `COLUMN_NAME`\n'
|
1797
|
-
'FROM `information_schema`.`COLUMNS`\n'
|
1819
|
+
' SELECT `TABLE_SCHEMA`, `TABLE_NAME`, `COLUMN_NAME`\n'
|
1820
|
+
' FROM `information_schema`.`COLUMNS`\n'
|
1798
1821
|
f'{where_column}'
|
1799
|
-
'ORDER BY `TABLE_SCHEMA`, `TABLE_NAME`, `ORDINAL_POSITION
|
1822
|
+
' ORDER BY `TABLE_SCHEMA`, `TABLE_NAME`, `ORDINAL_POSITION`\n'
|
1823
|
+
')'
|
1800
1824
|
)
|
1801
1825
|
result = self.execute(sql, filter_db=filter_db)
|
1802
1826
|
|
reydb/rfile.py
CHANGED
@@ -157,6 +157,33 @@ class DBFile(BaseDatabase):
|
|
157
157
|
'primary': 'md5',
|
158
158
|
'comment': 'File data table.'
|
159
159
|
}
|
160
|
+
|
161
|
+
]
|
162
|
+
|
163
|
+
## View.
|
164
|
+
views = [
|
165
|
+
|
166
|
+
### Data information.
|
167
|
+
{
|
168
|
+
'path': ('file', 'data_information'),
|
169
|
+
'select': (
|
170
|
+
'SELECT `b`.`last_time`, `a`.`md5`, `a`.`size`, `b`.`names`, `b`.`notes`\n'
|
171
|
+
'FROM `file`.`data` AS `a`\n'
|
172
|
+
'LEFT JOIN (\n'
|
173
|
+
' SELECT\n'
|
174
|
+
' `md5`,\n'
|
175
|
+
" GROUP_CONCAT(DISTINCT(`name`) ORDER BY `create_time` DESC SEPARATOR ' | ') AS `names`,\n"
|
176
|
+
" GROUP_CONCAT(DISTINCT(`note`) ORDER BY `create_time` DESC SEPARATOR ' | ') AS `notes`,\n"
|
177
|
+
' MAX(`create_time`) as `last_time`\n'
|
178
|
+
' FROM `file`.`information`\n'
|
179
|
+
' GROUP BY `md5`\n'
|
180
|
+
' ORDER BY `last_time` DESC\n'
|
181
|
+
') AS `b`\n'
|
182
|
+
'ON `a`.`md5` = `b`.`md5`\n'
|
183
|
+
'ORDER BY `last_time` DESC'
|
184
|
+
)
|
185
|
+
}
|
186
|
+
|
160
187
|
]
|
161
188
|
|
162
189
|
## View stats.
|
@@ -170,7 +197,7 @@ class DBFile(BaseDatabase):
|
|
170
197
|
'name': 'count',
|
171
198
|
'select': (
|
172
199
|
'SELECT COUNT(1)\n'
|
173
|
-
'FROM `file`.`information`'
|
200
|
+
f'FROM `{self.path_names['file']}`.`{self.path_names['file.information']}`'
|
174
201
|
),
|
175
202
|
'comment': 'File information count.'
|
176
203
|
},
|
@@ -178,7 +205,7 @@ class DBFile(BaseDatabase):
|
|
178
205
|
'name': 'count_data',
|
179
206
|
'select': (
|
180
207
|
'SELECT COUNT(1)\n'
|
181
|
-
'FROM `file`.`data`'
|
208
|
+
f'FROM `{self.path_names['file']}`.`{self.path_names['file.data']}`'
|
182
209
|
),
|
183
210
|
'comment': 'File data unique count.'
|
184
211
|
},
|
@@ -189,7 +216,7 @@ class DBFile(BaseDatabase):
|
|
189
216
|
' ROUND(AVG(`size`) / 1024),\n'
|
190
217
|
" ' KB'\n"
|
191
218
|
')\n'
|
192
|
-
'FROM `file`.`data
|
219
|
+
f'FROM `{self.path_names['file']}`.`{self.path_names['file.data']}`'
|
193
220
|
),
|
194
221
|
'comment': 'File average size.'
|
195
222
|
},
|
@@ -200,7 +227,7 @@ class DBFile(BaseDatabase):
|
|
200
227
|
' ROUND(MAX(`size`) / 1024),\n'
|
201
228
|
" ' KB'\n"
|
202
229
|
')\n'
|
203
|
-
'FROM `file`.`data
|
230
|
+
f'FROM `{self.path_names['file']}`.`{self.path_names['file.data']}`'
|
204
231
|
),
|
205
232
|
'comment': 'File maximum size.'
|
206
233
|
},
|
@@ -208,16 +235,17 @@ class DBFile(BaseDatabase):
|
|
208
235
|
'name': 'last_time',
|
209
236
|
'select': (
|
210
237
|
'SELECT MAX(`create_time`)\n'
|
211
|
-
'FROM `file`.`information`'
|
238
|
+
f'FROM `{self.path_names['file']}`.`{self.path_names['file.information']}`'
|
212
239
|
),
|
213
240
|
'comment': 'File last record create time.'
|
214
241
|
}
|
215
242
|
]
|
216
243
|
}
|
244
|
+
|
217
245
|
]
|
218
246
|
|
219
247
|
# Build.
|
220
|
-
self.rdatabase.build.build(databases, tables, views_stats
|
248
|
+
self.rdatabase.build.build(databases, tables, views, views_stats)
|
221
249
|
|
222
250
|
|
223
251
|
def upload(
|
@@ -352,11 +380,11 @@ class DBFile(BaseDatabase):
|
|
352
380
|
sql = (
|
353
381
|
'SELECT `name`, (\n'
|
354
382
|
' SELECT `bytes`\n'
|
355
|
-
' FROM `file`.`data`\n'
|
356
|
-
' WHERE `md5` = `information`.`md5`\n'
|
383
|
+
f' FROM `{self.path_names['file']}`.`{self.path_names['file.data']}`\n'
|
384
|
+
f' WHERE `md5` = `{self.path_names['file.information']}`.`md5`\n'
|
357
385
|
' LIMIT 1\n'
|
358
386
|
') AS `bytes`\n'
|
359
|
-
'FROM `file`.`information`\n'
|
387
|
+
f'FROM `{self.path_names['file']}`.`{self.path_names['file.information']}`\n'
|
360
388
|
'WHERE `file_id` = :file_id\n'
|
361
389
|
'LIMIT 1'
|
362
390
|
)
|
@@ -404,11 +432,11 @@ class DBFile(BaseDatabase):
|
|
404
432
|
sql = (
|
405
433
|
'SELECT `create_time`, `md5`, `name`, `note`, (\n'
|
406
434
|
' SELECT `size`\n'
|
407
|
-
' FROM `file`.`data`\n'
|
435
|
+
f' FROM `{self.path_names['file']}`.`{self.path_names['file.data']}`\n'
|
408
436
|
' WHERE `md5` = `a`.`md5`\n'
|
409
437
|
' LIMIT 1\n'
|
410
438
|
') AS `size`\n'
|
411
|
-
'FROM `file`.`information` AS `a`\n'
|
439
|
+
f'FROM `{self.path_names['file']}`.`{self.path_names['file.information']}` AS `a`\n'
|
412
440
|
'WHERE `file_id` = :file_id\n'
|
413
441
|
'LIMIT 1'
|
414
442
|
)
|
@@ -2,13 +2,13 @@ reydb/__init__.py,sha256=UetBDQylwFTWiPMKF1ZPW45A6mwYWWSYneTesl4xKBY,474
|
|
2
2
|
reydb/rall.py,sha256=i6-ph2cahhTTF17DjUYf6KX3DNxhEvy6iedlSeF4ibI,341
|
3
3
|
reydb/rbase.py,sha256=HMhxr7_TyzAusrv5dcc1hf3PmxGWj7m63kKcr5Ikbf4,312
|
4
4
|
reydb/rbuild.py,sha256=ppsaGWTC3S-zwQDj3keL3oF5TddORTuEpfqNElj6thU,32327
|
5
|
-
reydb/rconn.py,sha256=
|
6
|
-
reydb/rdb.py,sha256=
|
5
|
+
reydb/rconn.py,sha256=ZZDssqBCb1GQT61xG1N96-wYwISTIlKO1nJkgBuwBlI,6507
|
6
|
+
reydb/rdb.py,sha256=VVytmnw07MFC-gc3JzjJC50SJTXA0H-oy_pFtYf_ras,60895
|
7
7
|
reydb/rexec.py,sha256=kc5xSfuEDFW9rcAeJj_x6JWPDSYnHZQXcfSBXFGIhL8,8893
|
8
|
-
reydb/rfile.py,sha256=
|
8
|
+
reydb/rfile.py,sha256=VUJy7edvHq-D_KyJYm5gYS338l7sqCNAcwf3InpI2So,13664
|
9
9
|
reydb/rinfo.py,sha256=NhcFhzp9gQ49EpAqcFYXcG-FMUXu3qii8WGoHxN6UcQ,14250
|
10
10
|
reydb/rparam.py,sha256=EVSz_D4wyiaj5ZKxvdDcECmpbriOUNBBFCzz4bnV6dY,6838
|
11
|
-
reydb-1.1.
|
12
|
-
reydb-1.1.
|
13
|
-
reydb-1.1.
|
14
|
-
reydb-1.1.
|
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
|