Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
release_memory: bool, optional
Call ``self.deallocate_ipc(df)`` after DataFrame created
Returns
-------
df: pandas.DataFrame
Notes
-----
This method requires the Python code to be executed on the same machine
where OmniSci running.
"""
self.register_runtime_udfs()
if parameters is not None:
operation = str(_bind_parameters(operation, parameters))
tdf = self._client.sql_execute_df(
self._session, operation.strip(), device_type=0, device_id=0,
first_n=first_n
)
self._tdf = tdf
sm_buf = load_buffer(tdf.sm_handle, tdf.sm_size)
df_buf = load_buffer(tdf.df_handle, tdf.df_size)
schema = _load_schema(sm_buf[0])
df = _load_data(df_buf[0], schema, tdf)
# free shared memory from Python
# https://github.com/omnisci/pymapd/issues/46
# https://github.com/omnisci/pymapd/issues/31
>>> c.execute("select symbol, qty from stocks")
>>> list(c)
[('RHAT', 100.0), ('IBM', 1000.0), ('MSFT', 1000.0), ('IBM', 500.0)]
Passing in ``parameters``:
>>> c.execute("select symbol qty from stocks where qty <= :max_qty",
... parameters={"max_qty": 500})
[('RHAT', 100.0), ('IBM', 500.0)]
"""
# https://github.com/omnisci/pymapd/issues/263
operation = operation.strip()
if parameters is not None:
operation = str(_bind_parameters(operation, parameters))
self.rowcount = -1
try:
result = self.connection._client.sql_execute(
self.connection._session, operation,
column_format=True,
nonce=None, first_n=-1, at_most_n=-1)
except T.TMapDException as e:
raise _translate_exception(e) from e
self._description = _extract_description(result.row_set.row_desc)
try:
self.rowcount = len(result.row_set.columns[0].nulls)
except IndexError:
pass
self._result_set = make_row_results_set(result)
This method requires ``cudf`` and ``libcudf`` to be installed.
An ``ImportError`` is raised if those aren't available.
This method requires the Python code to be executed on the same machine
where OmniSci running.
"""
try:
from cudf.comm.gpuarrow import GpuArrowReader # noqa
from cudf.dataframe import DataFrame # noqa
except ImportError:
raise ImportError("The 'cudf' package is required for "
"`select_ipc_gpu`")
self.register_runtime_udfs()
if parameters is not None:
operation = str(_bind_parameters(operation, parameters))
tdf = self._client.sql_execute_gdf(
self._session, operation.strip(), device_id=device_id,
first_n=first_n)
self._tdf = tdf
df = _parse_tdf_gpu(tdf)
# Deallocate TDataFrame at OmniSci instance
if release_memory:
self.deallocate_ipc_gpu(df)
return df