reydb 1.1.53__py3-none-any.whl → 1.1.54__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 +26 -27
- reydb/rdb.py +57 -6
- reydb/rexec.py +5 -2
- {reydb-1.1.53.dist-info → reydb-1.1.54.dist-info}/METADATA +1 -1
- {reydb-1.1.53.dist-info → reydb-1.1.54.dist-info}/RECORD +7 -7
- {reydb-1.1.53.dist-info → reydb-1.1.54.dist-info}/WHEEL +0 -0
- {reydb-1.1.53.dist-info → reydb-1.1.54.dist-info}/licenses/LICENSE +0 -0
reydb/rconn.py
CHANGED
@@ -153,8 +153,7 @@ class DatabaseConnection(DatabaseBase):
|
|
153
153
|
self.commit()
|
154
154
|
|
155
155
|
# Close.
|
156
|
-
|
157
|
-
self.close()
|
156
|
+
self.close()
|
158
157
|
|
159
158
|
|
160
159
|
def insert_id(self) -> int:
|
@@ -200,9 +199,9 @@ class DatabaseConnectionAsync(DatabaseBase):
|
|
200
199
|
# Build.
|
201
200
|
self.db = db
|
202
201
|
self.autocommit = autocommit
|
203
|
-
self.
|
204
|
-
self.
|
205
|
-
self.
|
202
|
+
self.aexecute = DatabaseExecuteAsync(self)
|
203
|
+
self.aconn: AsyncConnection | None = None
|
204
|
+
self.abegin: AsyncTransaction | None = None
|
206
205
|
|
207
206
|
|
208
207
|
async def get_conn(self) -> AsyncConnection:
|
@@ -215,10 +214,10 @@ class DatabaseConnectionAsync(DatabaseBase):
|
|
215
214
|
"""
|
216
215
|
|
217
216
|
# Create.
|
218
|
-
if self.
|
219
|
-
self.
|
217
|
+
if self.aconn is None:
|
218
|
+
self.aconn = await self.db.aengine.connect()
|
220
219
|
|
221
|
-
return self.
|
220
|
+
return self.aconn
|
222
221
|
|
223
222
|
|
224
223
|
async def get_begin(self) -> AsyncTransaction:
|
@@ -231,11 +230,11 @@ class DatabaseConnectionAsync(DatabaseBase):
|
|
231
230
|
"""
|
232
231
|
|
233
232
|
# Create.
|
234
|
-
if self.
|
233
|
+
if self.abegin is None:
|
235
234
|
conn = await self.get_conn()
|
236
|
-
self.
|
235
|
+
self.abegin = await conn.begin()
|
237
236
|
|
238
|
-
return self.
|
237
|
+
return self.abegin
|
239
238
|
|
240
239
|
|
241
240
|
async def commit(self) -> None:
|
@@ -244,9 +243,9 @@ class DatabaseConnectionAsync(DatabaseBase):
|
|
244
243
|
"""
|
245
244
|
|
246
245
|
# Commit.
|
247
|
-
if self.
|
248
|
-
await self.
|
249
|
-
self.
|
246
|
+
if self.abegin is not None:
|
247
|
+
await self.abegin.commit()
|
248
|
+
self.abegin = None
|
250
249
|
|
251
250
|
|
252
251
|
async def rollback(self) -> None:
|
@@ -255,9 +254,9 @@ class DatabaseConnectionAsync(DatabaseBase):
|
|
255
254
|
"""
|
256
255
|
|
257
256
|
# Rollback.
|
258
|
-
if self.
|
259
|
-
await self.
|
260
|
-
self.
|
257
|
+
if self.abegin is not None:
|
258
|
+
await self.abegin.rollback()
|
259
|
+
self.abegin = None
|
261
260
|
|
262
261
|
|
263
262
|
async def close(self) -> None:
|
@@ -266,15 +265,15 @@ class DatabaseConnectionAsync(DatabaseBase):
|
|
266
265
|
"""
|
267
266
|
|
268
267
|
# Close.
|
269
|
-
if self.
|
270
|
-
await self.
|
271
|
-
self.
|
272
|
-
if self.
|
273
|
-
await self.
|
274
|
-
self.
|
268
|
+
if self.abegin is not None:
|
269
|
+
await self.abegin.close()
|
270
|
+
self.abegin = None
|
271
|
+
if self.aconn is not None:
|
272
|
+
await self.aconn.close()
|
273
|
+
self.aconn = None
|
275
274
|
|
276
275
|
|
277
|
-
async def __aenter__(self)
|
276
|
+
async def __aenter__(self):
|
278
277
|
"""
|
279
278
|
Asynchronous enter syntax `async with`.
|
280
279
|
|
@@ -304,8 +303,8 @@ class DatabaseConnectionAsync(DatabaseBase):
|
|
304
303
|
await self.commit()
|
305
304
|
|
306
305
|
# Close.
|
307
|
-
|
308
|
-
|
306
|
+
await self.close()
|
307
|
+
await self.db.dispose()
|
309
308
|
|
310
309
|
|
311
310
|
async def insert_id(self) -> int:
|
@@ -319,7 +318,7 @@ class DatabaseConnectionAsync(DatabaseBase):
|
|
319
318
|
|
320
319
|
# Get.
|
321
320
|
sql = 'SELECT LAST_INSERT_ID()'
|
322
|
-
result = await self.
|
321
|
+
result = await self.aexecute(sql)
|
323
322
|
id_ = result.scalar()
|
324
323
|
|
325
324
|
return id_
|
reydb/rdb.py
CHANGED
@@ -100,7 +100,8 @@ class Database(DatabaseBase):
|
|
100
100
|
"""
|
101
101
|
|
102
102
|
# Get.
|
103
|
-
|
103
|
+
url = self.url(False)
|
104
|
+
url_params = extract_url(url)
|
104
105
|
backend = url_params['backend']
|
105
106
|
|
106
107
|
return backend
|
@@ -117,17 +118,57 @@ class Database(DatabaseBase):
|
|
117
118
|
"""
|
118
119
|
|
119
120
|
# Get.
|
120
|
-
|
121
|
+
url = self.url(False)
|
122
|
+
url_params = extract_url(url)
|
121
123
|
driver = url_params['driver']
|
122
124
|
|
123
125
|
return driver
|
124
126
|
|
125
127
|
|
126
128
|
@property
|
127
|
-
def
|
129
|
+
def abackend(self) -> str:
|
130
|
+
"""
|
131
|
+
Asynchronous database backend name.
|
132
|
+
|
133
|
+
Returns
|
134
|
+
-------
|
135
|
+
Name.
|
136
|
+
"""
|
137
|
+
|
138
|
+
# Get.
|
139
|
+
url = self.url(True)
|
140
|
+
url_params = extract_url(url)
|
141
|
+
backend = url_params['backend']
|
142
|
+
|
143
|
+
return backend
|
144
|
+
|
145
|
+
|
146
|
+
@property
|
147
|
+
def adriver(self) -> str:
|
148
|
+
"""
|
149
|
+
Asynchronous database driver name.
|
150
|
+
|
151
|
+
Returns
|
152
|
+
-------
|
153
|
+
Name.
|
154
|
+
"""
|
155
|
+
|
156
|
+
# Get.
|
157
|
+
url = self.url(True)
|
158
|
+
url_params = extract_url(url)
|
159
|
+
driver = url_params['driver']
|
160
|
+
|
161
|
+
return driver
|
162
|
+
|
163
|
+
|
164
|
+
def url(self, is_async: bool) -> str:
|
128
165
|
"""
|
129
166
|
Generate server URL.
|
130
167
|
|
168
|
+
Parameters
|
169
|
+
----------
|
170
|
+
is_async : Whether to use asynchronous engine.
|
171
|
+
|
131
172
|
Returns
|
132
173
|
-------
|
133
174
|
Server URL.
|
@@ -135,7 +176,7 @@ class Database(DatabaseBase):
|
|
135
176
|
|
136
177
|
# Generate URL.
|
137
178
|
password = urllib_quote(self.password)
|
138
|
-
if
|
179
|
+
if is_async:
|
139
180
|
url_ = f'mysql+aiomysql://{self.username}:{password}@{self.host}:{self.port}/{self.database}'
|
140
181
|
else:
|
141
182
|
url_ = f'mysql+pymysql://{self.username}:{password}@{self.host}:{self.port}/{self.database}'
|
@@ -173,8 +214,9 @@ class Database(DatabaseBase):
|
|
173
214
|
"""
|
174
215
|
|
175
216
|
# Handle parameter.
|
217
|
+
url = self.url(is_async)
|
176
218
|
engine_params = {
|
177
|
-
'url':
|
219
|
+
'url': url,
|
178
220
|
'pool_size': self.pool_size,
|
179
221
|
'max_overflow': self.max_overflow,
|
180
222
|
'pool_timeout': self.pool_timeout,
|
@@ -191,6 +233,15 @@ class Database(DatabaseBase):
|
|
191
233
|
return engine
|
192
234
|
|
193
235
|
|
236
|
+
async def dispose(self) -> None:
|
237
|
+
"""
|
238
|
+
Dispose asynchronous connections.
|
239
|
+
"""
|
240
|
+
|
241
|
+
# Dispose.
|
242
|
+
await self.aengine.dispose()
|
243
|
+
|
244
|
+
|
194
245
|
def __conn_count(self, is_async: bool) -> tuple[int, int]:
|
195
246
|
"""
|
196
247
|
Count number of keep open and allowed overflow connection.
|
@@ -397,7 +448,7 @@ class Database(DatabaseBase):
|
|
397
448
|
|
398
449
|
# Build.
|
399
450
|
dbconn = self.aconnect(True)
|
400
|
-
exec = dbconn.
|
451
|
+
exec = dbconn.aexecute
|
401
452
|
|
402
453
|
return exec
|
403
454
|
|
reydb/rexec.py
CHANGED
@@ -716,6 +716,7 @@ class DatabaseExecute(DatabaseExecuteBase):
|
|
716
716
|
# Automatic commit.
|
717
717
|
if self.dbconn.autocommit:
|
718
718
|
self.dbconn.commit()
|
719
|
+
self.dbconn.close()
|
719
720
|
|
720
721
|
return result
|
721
722
|
|
@@ -1235,7 +1236,7 @@ class DatabaseExecuteAsync(DatabaseExecuteBase):
|
|
1235
1236
|
if report:
|
1236
1237
|
tm = TimeMark()
|
1237
1238
|
tm()
|
1238
|
-
result = await self.dbconn.
|
1239
|
+
result = await self.dbconn.aconn.execute(sql, data)
|
1239
1240
|
tm()
|
1240
1241
|
|
1241
1242
|
### Generate report.
|
@@ -1267,11 +1268,13 @@ class DatabaseExecuteAsync(DatabaseExecuteBase):
|
|
1267
1268
|
|
1268
1269
|
## Not report.
|
1269
1270
|
else:
|
1270
|
-
result = await self.dbconn.
|
1271
|
+
result = await self.dbconn.aconn.execute(sql, data)
|
1271
1272
|
|
1272
1273
|
# Automatic commit.
|
1273
1274
|
if self.dbconn.autocommit:
|
1274
1275
|
await self.dbconn.commit()
|
1276
|
+
await self.dbconn.close()
|
1277
|
+
await self.dbconn.db.dispose()
|
1275
1278
|
|
1276
1279
|
return result
|
1277
1280
|
|
@@ -3,15 +3,15 @@ reydb/rall.py,sha256=GsXHqvT1k--U53HpDY4SALjIHN8rwgSxeXpJjH5gq2E,409
|
|
3
3
|
reydb/rbase.py,sha256=rgAkEHLXDoMfiNCN2ckPQD-Eyd1tp0f122LEbI7L1Qg,8947
|
4
4
|
reydb/rbuild.py,sha256=6N8aLqCeX8JnOwQstVA2AuM0Rl5kUHx5Enrm2GGcGvo,31852
|
5
5
|
reydb/rconfig.py,sha256=UTpJ9psCrQlFx3FJ5_B8WkURRQ5PD6ZHLYg7MQRebmU,12659
|
6
|
-
reydb/rconn.py,sha256=
|
7
|
-
reydb/rdb.py,sha256=
|
6
|
+
reydb/rconn.py,sha256=VgzoI5gMHi5yMyUpLsPuMmuFkYDHCc0uuRXh_yUPY94,6551
|
7
|
+
reydb/rdb.py,sha256=SEozALLuJO16CrGDDz3kYRY9Ubt-Kh4wn9LibKnT23M,15944
|
8
8
|
reydb/rerror.py,sha256=Lsl7UECYdIFYjd9t7RhvNcHdyGStI3gffm8zmkK1DEc,9943
|
9
|
-
reydb/rexec.py,sha256=
|
9
|
+
reydb/rexec.py,sha256=sTb9IOldf6USK-Qo9xV03wHlniU7xAQHYZZKT3B0jPA,54099
|
10
10
|
reydb/rfile.py,sha256=RI1jMsNNJWvdky3oRV1Gw-9-tc1F92QjD24s2eusCVI,15184
|
11
11
|
reydb/rinfo.py,sha256=4btKBBZzVXGuPsmswqXDxvjZQuAc9raQ0tpXvmft71s,12741
|
12
12
|
reydb/rorm.py,sha256=JUwKZ9OgrI_FvTwTDfZhozpJB1v1xk_o3ESPLGTXXYI,23693
|
13
13
|
reydb/rparam.py,sha256=six7wwQRKycoscv-AGyQqsPjA4_TZgcGQ_jk7FZytQs,6803
|
14
|
-
reydb-1.1.
|
15
|
-
reydb-1.1.
|
16
|
-
reydb-1.1.
|
17
|
-
reydb-1.1.
|
14
|
+
reydb-1.1.54.dist-info/METADATA,sha256=TYQClPsAsRBW3S5s0NBbP4gzxkQMge1QMXNGksbhi8Y,1550
|
15
|
+
reydb-1.1.54.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
16
|
+
reydb-1.1.54.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
17
|
+
reydb-1.1.54.dist-info/RECORD,,
|
File without changes
|
File without changes
|