reydb 1.1.41__py3-none-any.whl → 1.1.43__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/rconfig.py +15 -1
- reydb/rdb.py +26 -13
- reydb/rerror.py +7 -1
- reydb/rfile.py +7 -1
- {reydb-1.1.41.dist-info → reydb-1.1.43.dist-info}/METADATA +1 -1
- {reydb-1.1.41.dist-info → reydb-1.1.43.dist-info}/RECORD +8 -8
- {reydb-1.1.41.dist-info → reydb-1.1.43.dist-info}/WHEEL +0 -0
- {reydb-1.1.41.dist-info → reydb-1.1.43.dist-info}/licenses/LICENSE +0 -0
reydb/rconfig.py
CHANGED
@@ -37,7 +37,7 @@ ConfigValueT = TypeVar('T', bound=ConfigValue) # Any.
|
|
37
37
|
class DatabaseConfig(object):
|
38
38
|
"""
|
39
39
|
Database config type.
|
40
|
-
Can create database used `self.
|
40
|
+
Can create database used `self.build_db` method.
|
41
41
|
|
42
42
|
Examples
|
43
43
|
--------
|
@@ -128,6 +128,20 @@ class DatabaseConfig(object):
|
|
128
128
|
}
|
129
129
|
],
|
130
130
|
'primary': 'key',
|
131
|
+
'indexes': [
|
132
|
+
{
|
133
|
+
'name': 'n_create_time',
|
134
|
+
'fields': 'create_time',
|
135
|
+
'type': 'noraml',
|
136
|
+
'comment': 'Config create time normal index.'
|
137
|
+
},
|
138
|
+
{
|
139
|
+
'name': 'n_update_time',
|
140
|
+
'fields': 'update_time',
|
141
|
+
'type': 'noraml',
|
142
|
+
'comment': 'Config update time normal index.'
|
143
|
+
}
|
144
|
+
],
|
131
145
|
'comment': 'Config data table.'
|
132
146
|
}
|
133
147
|
|
reydb/rdb.py
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
from typing import Any, Literal, overload
|
13
|
-
from collections.abc import Iterable, Generator
|
13
|
+
from collections.abc import Iterable, Generator, Container
|
14
14
|
from enum import EnumType
|
15
15
|
from urllib.parse import quote as urllib_quote
|
16
16
|
from pymysql.constants.CLIENT import MULTI_STATEMENTS
|
@@ -793,7 +793,7 @@ class Database(DatabaseBase):
|
|
793
793
|
self,
|
794
794
|
path: str | tuple[str, str],
|
795
795
|
data: TableData,
|
796
|
-
duplicate: Literal['ignore', 'update'] | None = None,
|
796
|
+
duplicate: Literal['ignore', 'update'] | Container[str] | None = None,
|
797
797
|
report: bool | None = None,
|
798
798
|
**kwdata: Any
|
799
799
|
) -> Result:
|
@@ -808,8 +808,9 @@ class Database(DatabaseBase):
|
|
808
808
|
data : Insert data.
|
809
809
|
duplicate : Handle method when constraint error.
|
810
810
|
- `None`: Not handled.
|
811
|
-
- `ignore
|
812
|
-
- `update
|
811
|
+
- `ignore`: Use `UPDATE IGNORE INTO` clause.
|
812
|
+
- `update`: Use `ON DUPLICATE KEY UPDATE` clause and update all fields.
|
813
|
+
- `Container[str]`: Use `ON DUPLICATE KEY UPDATE` clause and update this fields.
|
813
814
|
report : Whether report SQL execute information.
|
814
815
|
- `None`, Use attribute `report_execute_info`: of object `ROption`.
|
815
816
|
- `int`: Use this value.
|
@@ -901,6 +902,13 @@ class Database(DatabaseBase):
|
|
901
902
|
## Join sql part.
|
902
903
|
match duplicate:
|
903
904
|
|
905
|
+
### Not handle.
|
906
|
+
case None:
|
907
|
+
sql = (
|
908
|
+
f'INSERT INTO `{database}`.`{table}`({sql_fields})\n'
|
909
|
+
f'VALUES({sql_values})'
|
910
|
+
)
|
911
|
+
|
904
912
|
### Ignore.
|
905
913
|
case 'ignore':
|
906
914
|
sql = (
|
@@ -909,8 +917,20 @@ class Database(DatabaseBase):
|
|
909
917
|
)
|
910
918
|
|
911
919
|
### Update.
|
912
|
-
case
|
913
|
-
|
920
|
+
case _:
|
921
|
+
sql_fields_list_update = sql_fields_list
|
922
|
+
if duplicate != 'update':
|
923
|
+
sql_fields_list_update = [
|
924
|
+
field
|
925
|
+
for field in sql_fields_list
|
926
|
+
if field in duplicate
|
927
|
+
]
|
928
|
+
update_content = ',\n '.join(
|
929
|
+
[
|
930
|
+
f'`{field}` = VALUES(`{field}`)'
|
931
|
+
for field in sql_fields_list_update
|
932
|
+
]
|
933
|
+
)
|
914
934
|
sql = (
|
915
935
|
f'INSERT INTO `{database}`.`{table}`({sql_fields})\n'
|
916
936
|
f'VALUES({sql_values})\n'
|
@@ -918,13 +938,6 @@ class Database(DatabaseBase):
|
|
918
938
|
f' {update_content}'
|
919
939
|
)
|
920
940
|
|
921
|
-
### Not handle.
|
922
|
-
case _:
|
923
|
-
sql = (
|
924
|
-
f'INSERT INTO `{database}`.`{table}`({sql_fields})\n'
|
925
|
-
f'VALUES({sql_values})'
|
926
|
-
)
|
927
|
-
|
928
941
|
# Execute SQL.
|
929
942
|
result = self.execute(sql, data, report, **kwdata_replace)
|
930
943
|
|
reydb/rerror.py
CHANGED
@@ -28,7 +28,7 @@ __all__ = (
|
|
28
28
|
class DatabaseError(DatabaseBase):
|
29
29
|
"""
|
30
30
|
Database error type.
|
31
|
-
Can create database used `self.
|
31
|
+
Can create database used `self.build_db` method.
|
32
32
|
"""
|
33
33
|
|
34
34
|
|
@@ -114,6 +114,12 @@ class DatabaseError(DatabaseBase):
|
|
114
114
|
],
|
115
115
|
'primary': 'id',
|
116
116
|
'indexes': [
|
117
|
+
{
|
118
|
+
'name': 'n_create_time',
|
119
|
+
'fields': 'create_time',
|
120
|
+
'type': 'noraml',
|
121
|
+
'comment': 'Record create time normal index.'
|
122
|
+
},
|
117
123
|
{
|
118
124
|
'name': 'n_type',
|
119
125
|
'fields': 'type',
|
reydb/rfile.py
CHANGED
@@ -30,7 +30,7 @@ FileInfo = TypedDict('FileInfo', {'create_time': datetime, 'md5': str, 'name': s
|
|
30
30
|
class DatabaseFile(DatabaseBase):
|
31
31
|
"""
|
32
32
|
Database file type.
|
33
|
-
Can create database used `self.
|
33
|
+
Can create database used `self.build_db` method.
|
34
34
|
"""
|
35
35
|
|
36
36
|
|
@@ -113,6 +113,12 @@ class DatabaseFile(DatabaseBase):
|
|
113
113
|
],
|
114
114
|
'primary': 'file_id',
|
115
115
|
'indexes': [
|
116
|
+
{
|
117
|
+
'name': 'n_create_time',
|
118
|
+
'fields': 'create_time',
|
119
|
+
'type': 'noraml',
|
120
|
+
'comment': 'Record create time normal index.'
|
121
|
+
},
|
116
122
|
{
|
117
123
|
'name': 'n_md5',
|
118
124
|
'fields': 'md5',
|
@@ -2,15 +2,15 @@ reydb/__init__.py,sha256=SqjJEBMiUMnKkNfmOvw_jprZcj9Edi0jyBKt67xeYUE,544
|
|
2
2
|
reydb/rall.py,sha256=UWnbtl4oG4YqXyqTMN_5uqE-QqD5nb_-dvarotlTUeU,388
|
3
3
|
reydb/rbase.py,sha256=HYoFasGBAhXUUHNFP1doGnHBW3-xkgRc32O9KppGSak,4824
|
4
4
|
reydb/rbuild.py,sha256=iXJ76BNlUflJfMAAEbPuQLyVePyye8aDq7MaXD16Ktw,32419
|
5
|
-
reydb/rconfig.py,sha256=
|
5
|
+
reydb/rconfig.py,sha256=akY9zDQ7chmA5Hkf7Q7F_Oqqjn6gDk9B88dyLQEYMak,12886
|
6
6
|
reydb/rconn.py,sha256=YWscFMjBph9ttPXjzTTpaziTd7v7vnE0b7E4mVpJ6oc,6163
|
7
|
-
reydb/rdb.py,sha256=
|
8
|
-
reydb/rerror.py,sha256=
|
7
|
+
reydb/rdb.py,sha256=3Kr8U6YoxExfUhiaSXUzvfwhOyAdcNZJYicr0Bb8zX4,54791
|
8
|
+
reydb/rerror.py,sha256=cyY-jX6hWi1Ozp3Op0MhprrGBNNIy_nqupaNnHOhBmQ,10232
|
9
9
|
reydb/rexec.py,sha256=dGdRkG1XR0Z66T0r4nPCSdQzSRWc_Q3t6TPSSrDTIxY,9042
|
10
|
-
reydb/rfile.py,sha256=
|
10
|
+
reydb/rfile.py,sha256=kFKcExyU8PjWRTr6j7ZPB4qJqFMdYNDB77Nkpw4vHcE,15519
|
11
11
|
reydb/rinfo.py,sha256=KXTkcpTGAD3p9RVKKcnmc_FjJtiKRPk-K5ZepPOnphQ,15253
|
12
12
|
reydb/rparam.py,sha256=6cnSjNlX54iPS1uxMQdpazPM5XL4J87vVgfL6CIYG3U,7031
|
13
|
-
reydb-1.1.
|
14
|
-
reydb-1.1.
|
15
|
-
reydb-1.1.
|
16
|
-
reydb-1.1.
|
13
|
+
reydb-1.1.43.dist-info/METADATA,sha256=a467RImwupOg5cu_SD9ozAi3MCa__svKbH-wAzoAXVY,1550
|
14
|
+
reydb-1.1.43.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
15
|
+
reydb-1.1.43.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
16
|
+
reydb-1.1.43.dist-info/RECORD,,
|
File without changes
|
File without changes
|