pytd.query_engine.HiveQueryEngine
- class pytd.query_engine.HiveQueryEngine(apikey: str, endpoint: str, database: str, header: str | bool)[source]
An interface to Treasure Data Hive query engine.
- Parameters:
apikey (str) – Treasure Data API key.
endpoint (str) – Treasure Data API server.
database (str) – Name of connected database.
header (str or bool) – Prepend comment strings, in the form “– comment”, as a header of queries.
Methods
__init__(apikey, endpoint, database, header)close()Close a connection to Hive.
create_header([extra_lines])Build header comments.
cursor([force_tdclient])Get cursor defined by DB-API.
execute(query, **kwargs)Execute a given SQL statement and return results.
Attributes
User agent passed to a Hive connection.
- property user_agent: str
User agent passed to a Hive connection.
- cursor(force_tdclient: bool = True, **kwargs: Any) Cursor[source]
Get cursor defined by DB-API.
- Parameters:
force_tdclient (bool) – Specify whether the method always returns
tdclient.cursor.Cursor. Currently, the parameter changes nothing inHiveQueryEnginesincetdclient.cursor.Curosris the only option as a type of returned value.**kwargs –
Treasure Data-specific optional query parameters. Giving these keyword arguments forces query engine to issue a query via Treasure Data REST API provided by
tdclient.db(str): use the databaseresult_url(str): result output URLpriority(int or str): priority-2: “VERY LOW”
-1: “LOW”
0: “NORMAL”
1: “HIGH”
2: “VERY HIGH”
retry_limit(int): max number of automatic retrieswait_interval(int): sleep interval until job finishwait_callback(function): called every interval against job itselfengine_version(str): run query with Hive 2 if this parameter is set to"stable". https://api-docs.treasuredata.com/en/tools/hive/writing_hive_queries
- Return type:
tdclient.cursor.Cursor