mysqlengine 0.1.11.8__cp312-cp312-win_amd64.whl → 0.1.12.1__cp312-cp312-win_amd64.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.

Potentially problematic release.


This version of mysqlengine might be problematic. Click here for more details.

Binary file
mysqlengine/query.py CHANGED
@@ -47,8 +47,8 @@ from decimal import Decimal
47
47
  from time import struct_time
48
48
  from asyncio import gather, Semaphore
49
49
  from re import compile, Pattern, IGNORECASE
50
- from typing import Self, Any, Union, Literal, Callable, TYPE_CHECKING
51
50
  from _collections_abc import dict_values as dict_val, dict_keys as dict_key
51
+ from typing import Self, Any, Union, Literal, Callable, TYPE_CHECKING, overload
52
52
  import numpy as np, pandas as pd
53
53
  from pandas import DataFrame, Series, concat
54
54
  from cytimes.pydt import pydt
@@ -5356,6 +5356,198 @@ class SelectQuery(SelectShare):
5356
5356
  return self._validate_stmt(stmt)
5357
5357
 
5358
5358
  # Execute ------------------------------------------------------------------------------------
5359
+ @overload
5360
+ async def execute(
5361
+ self,
5362
+ conn: Union[Connection, None] = None,
5363
+ concurrency: int = 10,
5364
+ cursor: type[DictCursor | SSDictCursor] = DictCursor,
5365
+ timeout: Union[int, None] = None,
5366
+ warnings: bool = True,
5367
+ *,
5368
+ retry_on_error: bool = True,
5369
+ retry_times: int = -1,
5370
+ min_wait_time: float = 0.2,
5371
+ max_wait_time: float = 2,
5372
+ stats: bool = False,
5373
+ ) -> tuple[dict[str, Any]]:
5374
+ """Execute the SELECT query.
5375
+
5376
+ :param conn: `<Connection>` The connection to execute the query. Defaults to `None`.
5377
+ - If `None`, query will be executed by temporary connections
5378
+ acquired from the Server pool.
5379
+ - If specified, query will be executed by the given connection.
5380
+
5381
+ :param concurrency: `<int>` The maximum number of concurrent executions. Defaults to `10`.
5382
+ - When the query is consists of multiple sub-queries (For example, select
5383
+ data from different sub-tables of a TimeTable), this argument determines
5384
+ the maximum number of concurrent query executions at the same time.
5385
+ - * Notice: This argument is only applicable when `conn=None`. If 'conn'
5386
+ is specified, all sub-queries will be executed sequentially by the
5387
+ given connection.
5388
+
5389
+ :param cursor: `<type[Cursor]>` The `Cursor` class to use for query execution. Defaults to `DictCursor`.
5390
+ - `DictCursor/SSDictCursor`: Fetch result as `<tuple[dict]>`.
5391
+ - `DfCursor/SSDfCursor`: Fetch result as `<pandas.DataFrame>`.
5392
+ - `Cursor/SSCursor`: Fetch result as `<tuple[tuple]>` (without column names).
5393
+
5394
+ :param timeout: `<int>` Query execution timeout in seconds. Dafaults to `None`.
5395
+ - If set to `None` or `0`, `tables.server.query_timeout` will be used
5396
+ as the default timeout.
5397
+ - `SQLQueryTimeoutError` will be raised when the timeout is reached.
5398
+
5399
+ :param warnings: `<bool>` Whether to issue any SQL related warnings. Defaults to `True`.
5400
+
5401
+ :param retry_on_error: `<bool>` Whether to retry when non-critial SQL error occurs. Defaults to `True`.
5402
+ - If `True`, when a non-critical SQL error occurs (such as `connection timeout`,
5403
+ `connection lost`, etc.), the query will be retried.
5404
+ - If `False`, errors will be raised immediately.
5405
+
5406
+ :param retry_times: `<int>` The maximum number of retries. Defaults to `-1`.
5407
+ - * Notice: This argument is only applicable when `retry_on_error=True`.
5408
+ - For `retry_times <= 0`, the query retries indefinitely until success.
5409
+ - For `retry_times > 0`, the query retries up to the given 'retry_times'.
5410
+
5411
+ :param min_wait_time: `<float>` The minimum wait time in seconds between each retries. Defaults to `0.2`.
5412
+ - * Notice: This argument is only applicable when `retry_on_error=True`.
5413
+
5414
+ :param max_wait_time: `<float>` The maximum wait time in seconds between each retries. Defaults to `2`.
5415
+ - * Notice: This argument is only applicable when `retry_on_error=True`.
5416
+
5417
+ :param stats: `<bool>` Whether to print the query execution stats to the console. Defaults to `False`.
5418
+ :raises: Subclass of `QueryError`.
5419
+ :return `<tuple[dict]>`: The fetched result.
5420
+ """
5421
+ ...
5422
+
5423
+ @overload
5424
+ async def execute(
5425
+ self,
5426
+ conn: Union[Connection, None] = None,
5427
+ concurrency: int = 10,
5428
+ cursor: type[DfCursor | SSDfCursor] = DictCursor,
5429
+ timeout: Union[int, None] = None,
5430
+ warnings: bool = True,
5431
+ *,
5432
+ retry_on_error: bool = True,
5433
+ retry_times: int = -1,
5434
+ min_wait_time: float = 0.2,
5435
+ max_wait_time: float = 2,
5436
+ stats: bool = False,
5437
+ ) -> DataFrame:
5438
+ """Execute the SELECT query.
5439
+
5440
+ :param conn: `<Connection>` The connection to execute the query. Defaults to `None`.
5441
+ - If `None`, query will be executed by temporary connections
5442
+ acquired from the Server pool.
5443
+ - If specified, query will be executed by the given connection.
5444
+
5445
+ :param concurrency: `<int>` The maximum number of concurrent executions. Defaults to `10`.
5446
+ - When the query is consists of multiple sub-queries (For example, select
5447
+ data from different sub-tables of a TimeTable), this argument determines
5448
+ the maximum number of concurrent query executions at the same time.
5449
+ - * Notice: This argument is only applicable when `conn=None`. If 'conn'
5450
+ is specified, all sub-queries will be executed sequentially by the
5451
+ given connection.
5452
+
5453
+ :param cursor: `<type[Cursor]>` The `Cursor` class to use for query execution. Defaults to `DictCursor`.
5454
+ - `DictCursor/SSDictCursor`: Fetch result as `<tuple[dict]>`.
5455
+ - `DfCursor/SSDfCursor`: Fetch result as `<pandas.DataFrame>`.
5456
+ - `Cursor/SSCursor`: Fetch result as `<tuple[tuple]>` (without column names).
5457
+
5458
+ :param timeout: `<int>` Query execution timeout in seconds. Dafaults to `None`.
5459
+ - If set to `None` or `0`, `tables.server.query_timeout` will be used
5460
+ as the default timeout.
5461
+ - `SQLQueryTimeoutError` will be raised when the timeout is reached.
5462
+
5463
+ :param warnings: `<bool>` Whether to issue any SQL related warnings. Defaults to `True`.
5464
+
5465
+ :param retry_on_error: `<bool>` Whether to retry when non-critial SQL error occurs. Defaults to `True`.
5466
+ - If `True`, when a non-critical SQL error occurs (such as `connection timeout`,
5467
+ `connection lost`, etc.), the query will be retried.
5468
+ - If `False`, errors will be raised immediately.
5469
+
5470
+ :param retry_times: `<int>` The maximum number of retries. Defaults to `-1`.
5471
+ - * Notice: This argument is only applicable when `retry_on_error=True`.
5472
+ - For `retry_times <= 0`, the query retries indefinitely until success.
5473
+ - For `retry_times > 0`, the query retries up to the given 'retry_times'.
5474
+
5475
+ :param min_wait_time: `<float>` The minimum wait time in seconds between each retries. Defaults to `0.2`.
5476
+ - * Notice: This argument is only applicable when `retry_on_error=True`.
5477
+
5478
+ :param max_wait_time: `<float>` The maximum wait time in seconds between each retries. Defaults to `2`.
5479
+ - * Notice: This argument is only applicable when `retry_on_error=True`.
5480
+
5481
+ :param stats: `<bool>` Whether to print the query execution stats to the console. Defaults to `False`.
5482
+ :raises: Subclass of `QueryError`.
5483
+ :return `<DataFrame>`: The fetched result.
5484
+ """
5485
+ ...
5486
+
5487
+ @overload
5488
+ async def execute(
5489
+ self,
5490
+ conn: Union[Connection, None] = None,
5491
+ concurrency: int = 10,
5492
+ cursor: type[Cursor | SSCursor] = DictCursor,
5493
+ timeout: Union[int, None] = None,
5494
+ warnings: bool = True,
5495
+ *,
5496
+ retry_on_error: bool = True,
5497
+ retry_times: int = -1,
5498
+ min_wait_time: float = 0.2,
5499
+ max_wait_time: float = 2,
5500
+ stats: bool = False,
5501
+ ) -> tuple[tuple[Any]]:
5502
+ """Execute the SELECT query.
5503
+
5504
+ :param conn: `<Connection>` The connection to execute the query. Defaults to `None`.
5505
+ - If `None`, query will be executed by temporary connections
5506
+ acquired from the Server pool.
5507
+ - If specified, query will be executed by the given connection.
5508
+
5509
+ :param concurrency: `<int>` The maximum number of concurrent executions. Defaults to `10`.
5510
+ - When the query is consists of multiple sub-queries (For example, select
5511
+ data from different sub-tables of a TimeTable), this argument determines
5512
+ the maximum number of concurrent query executions at the same time.
5513
+ - * Notice: This argument is only applicable when `conn=None`. If 'conn'
5514
+ is specified, all sub-queries will be executed sequentially by the
5515
+ given connection.
5516
+
5517
+ :param cursor: `<type[Cursor]>` The `Cursor` class to use for query execution. Defaults to `DictCursor`.
5518
+ - `DictCursor/SSDictCursor`: Fetch result as `<tuple[dict]>`.
5519
+ - `DfCursor/SSDfCursor`: Fetch result as `<pandas.DataFrame>`.
5520
+ - `Cursor/SSCursor`: Fetch result as `<tuple[tuple]>` (without column names).
5521
+
5522
+ :param timeout: `<int>` Query execution timeout in seconds. Dafaults to `None`.
5523
+ - If set to `None` or `0`, `tables.server.query_timeout` will be used
5524
+ as the default timeout.
5525
+ - `SQLQueryTimeoutError` will be raised when the timeout is reached.
5526
+
5527
+ :param warnings: `<bool>` Whether to issue any SQL related warnings. Defaults to `True`.
5528
+
5529
+ :param retry_on_error: `<bool>` Whether to retry when non-critial SQL error occurs. Defaults to `True`.
5530
+ - If `True`, when a non-critical SQL error occurs (such as `connection timeout`,
5531
+ `connection lost`, etc.), the query will be retried.
5532
+ - If `False`, errors will be raised immediately.
5533
+
5534
+ :param retry_times: `<int>` The maximum number of retries. Defaults to `-1`.
5535
+ - * Notice: This argument is only applicable when `retry_on_error=True`.
5536
+ - For `retry_times <= 0`, the query retries indefinitely until success.
5537
+ - For `retry_times > 0`, the query retries up to the given 'retry_times'.
5538
+
5539
+ :param min_wait_time: `<float>` The minimum wait time in seconds between each retries. Defaults to `0.2`.
5540
+ - * Notice: This argument is only applicable when `retry_on_error=True`.
5541
+
5542
+ :param max_wait_time: `<float>` The maximum wait time in seconds between each retries. Defaults to `2`.
5543
+ - * Notice: This argument is only applicable when `retry_on_error=True`.
5544
+
5545
+ :param stats: `<bool>` Whether to print the query execution stats to the console. Defaults to `False`.
5546
+ :raises: Subclass of `QueryError`.
5547
+ :return `<tuple[tuple]>`: The fetched result.
5548
+ """
5549
+ ...
5550
+
5359
5551
  async def execute(
5360
5552
  self,
5361
5553
  conn: Union[Connection, None] = None,
@@ -5371,7 +5563,7 @@ class SelectQuery(SelectShare):
5371
5563
  min_wait_time: float = 0.2,
5372
5564
  max_wait_time: float = 2,
5373
5565
  stats: bool = False,
5374
- ) -> Union[tuple[dict | tuple], DataFrame]:
5566
+ ) -> Union[tuple[dict[str, Any] | tuple[Any]], DataFrame]:
5375
5567
  """Execute the SELECT query.
5376
5568
 
5377
5569
  :param conn: `<Connection>` The connection to execute the query. Defaults to `None`.
@@ -5389,8 +5581,8 @@ class SelectQuery(SelectShare):
5389
5581
 
5390
5582
  :param cursor: `<type[Cursor]>` The `Cursor` class to use for query execution. Defaults to `DictCursor`.
5391
5583
  - `DictCursor/SSDictCursor`: Fetch result as `<tuple[dict]>`.
5392
- - `DfCursor/SSDfCursor`: Fetch result as `pandas.DataFrame`.
5393
- - `Cursor/SSCursor`: Fetch result as `<tuple[Any]>` (without column names).
5584
+ - `DfCursor/SSDfCursor`: Fetch result as `<pandas.DataFrame>`.
5585
+ - `Cursor/SSCursor`: Fetch result as `<tuple[tuple]>` (without column names).
5394
5586
 
5395
5587
  :param timeout: `<int>` Query execution timeout in seconds. Dafaults to `None`.
5396
5588
  - If set to `None` or `0`, `tables.server.query_timeout` will be used
@@ -5417,7 +5609,7 @@ class SelectQuery(SelectShare):
5417
5609
 
5418
5610
  :param stats: `<bool>` Whether to print the query execution stats to the console. Defaults to `False`.
5419
5611
  :raises: Subclass of `QueryError`.
5420
- :return `<tuple/DataFrame>`: The fetched result (depends on 'cursor' type).
5612
+ :return `<tuple[tuple]/tuple[dict]/DataFrame>`: The fetched result (depends on 'cursor' type).
5421
5613
  """
5422
5614
  # Set parameters
5423
5615
  self._concurrency = concurrency
Binary file
Binary file