airflow.providers.exasol.hooks.exasol

Module Contents

class airflow.providers.exasol.hooks.exasol.ExasolHook(*args, **kwargs)[source]

Bases: airflow.hooks.dbapi.DbApiHook

Interact with Exasol. You can specify the pyexasol compression, encryption, json_lib and client_name parameters in the extra field of your connection as {"compression": True, "json_lib": "rapidjson", etc}. See pyexasol reference for more details.

conn_name_attr = exasol_conn_id[source]
default_conn_name = exasol_default[source]
conn_type = exasol[source]
hook_name = Exasol[source]
supports_autocommit = True[source]
get_conn(self)[source]
get_pandas_df(self, sql: Union[str, list], parameters: Optional[dict] = None, **kwargs)[source]

Executes the sql and returns a pandas dataframe

Parameters
  • sql (str or list) -- the sql statement to be executed (str) or a list of sql statements to execute

  • parameters (dict or iterable) -- The parameters to render the SQL query with.

  • kwargs (dict) -- (optional) passed into pyexasol.ExaConnection.export_to_pandas method

get_records(self, sql: Union[str, list], parameters: Optional[dict] = None)[source]

Executes the sql and returns a set of records.

Parameters
  • sql (str or list) -- the sql statement to be executed (str) or a list of sql statements to execute

  • parameters (dict or iterable) -- The parameters to render the SQL query with.

get_first(self, sql: Union[str, list], parameters: Optional[dict] = None)[source]

Executes the sql and returns the first resulting row.

Parameters
  • sql (str or list) -- the sql statement to be executed (str) or a list of sql statements to execute

  • parameters (dict or iterable) -- The parameters to render the SQL query with.

export_to_file(self, filename: str, query_or_table: str, query_params: Optional[Dict] = None, export_params: Optional[Dict] = None)[source]

Exports data to a file.

Parameters
  • filename (str) -- Path to the file to which the data has to be exported

  • query_or_table (str) -- the sql statement to be executed or table name to export

  • query_params (dict) -- Query parameters passed to underlying export_to_file method of ExaConnection.

  • export_params (dict) -- Extra parameters passed to underlying export_to_file method of ExaConnection.

run(self, sql: Union[str, list], autocommit: bool = False, parameters: Optional[dict] = None)[source]

Runs a command or a list of commands. Pass a list of sql statements to the sql parameter to get them to execute sequentially

Parameters
  • sql (str or list) -- the sql statement to be executed (str) or a list of sql statements to execute

  • autocommit (bool) -- What to set the connection's autocommit setting to before executing the query.

  • parameters (dict or iterable) -- The parameters to render the SQL query with.

set_autocommit(self, conn, autocommit: bool)[source]

Sets the autocommit flag on the connection

Parameters
  • conn (connection object) -- Connection to set autocommit setting to.

  • autocommit (bool) -- The autocommit setting to set.

get_autocommit(self, conn)[source]

Get autocommit setting for the provided connection. Return True if autocommit is set. Return False if autocommit is not set or set to False or conn does not support autocommit.

Parameters

conn (connection object) -- Connection to get autocommit setting from.

Returns

connection autocommit setting.

Return type

bool

Was this entry helpful?