detquantlib 5.10.0__tar.gz → 5.10.1__tar.gz
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.
- {detquantlib-5.10.0 → detquantlib-5.10.1}/PKG-INFO +1 -1
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/data/databases/snowflake_client.py +39 -4
- {detquantlib-5.10.0 → detquantlib-5.10.1}/pyproject.toml +1 -1
- {detquantlib-5.10.0 → detquantlib-5.10.1}/LICENSE.txt +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/README.md +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/__init__.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/assets/__init__.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/assets/battery.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/assets/wind_turbine.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/converters/__init__.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/converters/definitions.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/converters/energy.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/converters/helpers.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/converters/price.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/data/__init__.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/data/databases/azure_client.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/data/databases/detdatabase.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/data/databases/helpers.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/data/entsoe/entsoe.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/data/sftp/sftp.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/data/tennet/tennet_client.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/dates/__init__.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/dates/dates.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/figures/__init__.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/figures/plotly_figures.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/forecasting/__init__.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/forecasting/forecasting.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/outputs/__init__.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/outputs/outputs_interface.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/snapshot_testing/README.md +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/snapshot_testing/__init__.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/snapshot_testing/cases.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/snapshot_testing/comparison.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/snapshot_testing/config.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/snapshot_testing/errors.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/snapshot_testing/isolation.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/snapshot_testing/pytest_plugin.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/snapshot_testing/recording.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/snapshot_testing/tables.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/stats/__init__.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/stats/data_analysis.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/tradable_products/__init__.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/tradable_products/tradable_products.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/utils/__init__.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/utils/logging.py +0 -0
- {detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/utils/utils.py +0 -0
|
@@ -286,7 +286,9 @@ class SnowflakeClient:
|
|
|
286
286
|
Args:
|
|
287
287
|
sql: The SQL statement to execute.
|
|
288
288
|
params: Values bound to the placeholders in ``sql``: a sequence for positional ``%s``
|
|
289
|
-
placeholders, or a dict for named ``%(name)s`` placeholders.
|
|
289
|
+
placeholders, or a dict for named ``%(name)s`` placeholders. pandas Timestamps
|
|
290
|
+
are converted to Python datetimes (and ``NaT`` to ``None``), since the connector
|
|
291
|
+
cannot bind them.
|
|
290
292
|
lowercase_columns: If ``True``, column names in the result are converted to lowercase
|
|
291
293
|
(Snowflake returns them uppercase by default).
|
|
292
294
|
|
|
@@ -299,7 +301,7 @@ class SnowflakeClient:
|
|
|
299
301
|
conn = self.connect()
|
|
300
302
|
try:
|
|
301
303
|
with conn.cursor() as cur:
|
|
302
|
-
cur.execute(sql, params)
|
|
304
|
+
cur.execute(sql, self._prepare_params(params))
|
|
303
305
|
df = cur.fetch_pandas_all()
|
|
304
306
|
except SnowflakeError as e:
|
|
305
307
|
logger.error("Query failed: %s", e)
|
|
@@ -329,7 +331,7 @@ class SnowflakeClient:
|
|
|
329
331
|
"""
|
|
330
332
|
conn = self.connect()
|
|
331
333
|
with conn.cursor() as cur:
|
|
332
|
-
cur.execute(sql, params)
|
|
334
|
+
cur.execute(sql, self._prepare_params(params))
|
|
333
335
|
for batch in cur.fetch_pandas_batches():
|
|
334
336
|
yield batch
|
|
335
337
|
|
|
@@ -492,7 +494,7 @@ class SnowflakeClient:
|
|
|
492
494
|
conn = self.connect()
|
|
493
495
|
try:
|
|
494
496
|
with conn.cursor() as cur:
|
|
495
|
-
cur.execute(sql, params)
|
|
497
|
+
cur.execute(sql, self._prepare_params(params))
|
|
496
498
|
rowcount = cur.rowcount
|
|
497
499
|
except SnowflakeError as e:
|
|
498
500
|
logger.error("Statement failed: %s", e)
|
|
@@ -500,6 +502,39 @@ class SnowflakeClient:
|
|
|
500
502
|
logger.info("Statement affected %s rows", rowcount)
|
|
501
503
|
return rowcount
|
|
502
504
|
|
|
505
|
+
@staticmethod
|
|
506
|
+
def _prepare_params(
|
|
507
|
+
params: Optional[Union[Sequence[Any], dict[str, Any]]],
|
|
508
|
+
) -> Optional[Union[tuple[Any, ...], dict[str, Any]]]:
|
|
509
|
+
"""
|
|
510
|
+
Converts parameter values that the Snowflake connector cannot bind.
|
|
511
|
+
|
|
512
|
+
The connector picks a converter by type name, so it rejects pandas Timestamps even though
|
|
513
|
+
they are datetime subclasses. They are converted to Python datetimes, and ``NaT`` to
|
|
514
|
+
``None``. Note that Python datetimes only have microsecond precision, so nanoseconds are
|
|
515
|
+
dropped (pandas warns when this happens). Other values are passed through unchanged.
|
|
516
|
+
|
|
517
|
+
Args:
|
|
518
|
+
params: Values bound to the placeholders of a query, as in ``query()``.
|
|
519
|
+
|
|
520
|
+
Returns:
|
|
521
|
+
The converted values, as a dict for named placeholders or a tuple for positional
|
|
522
|
+
ones, or ``None`` if ``params`` is ``None``.
|
|
523
|
+
"""
|
|
524
|
+
if params is None:
|
|
525
|
+
return None
|
|
526
|
+
|
|
527
|
+
def convert(value: Any) -> Any:
|
|
528
|
+
if value is pd.NaT:
|
|
529
|
+
return None
|
|
530
|
+
if isinstance(value, pd.Timestamp):
|
|
531
|
+
return value.to_pydatetime()
|
|
532
|
+
return value
|
|
533
|
+
|
|
534
|
+
if isinstance(params, dict):
|
|
535
|
+
return {k: convert(v) for k, v in params.items()}
|
|
536
|
+
return tuple(convert(v) for v in params)
|
|
537
|
+
|
|
503
538
|
@staticmethod
|
|
504
539
|
def _check_identifier(name: str) -> str:
|
|
505
540
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{detquantlib-5.10.0 → detquantlib-5.10.1}/detquantlib/tradable_products/tradable_products.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|