pytd.query_engine.PrestoQueryEngine¶
-
class
pytd.query_engine.
PrestoQueryEngine
(apikey, endpoint, database, header)[source]¶ An interface to Treasure Data Presto query engine.
- Parameters
- apikeystring
Treasure Data API key.
- endpointstring
Treasure Data API server.
- databasestring
Name of connected database.
- headerstring or boolean
Prepend comment strings, in the form “– comment”, as a header of queries.
-
__init__
(self, apikey, endpoint, database, header)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(self, apikey, endpoint, database, …)Initialize self.
close
(self)Close a connection to Presto.
create_header
(self[, extra_lines])Build header comments.
cursor
(self, \*\*kwargs)Get cursor defined by DB-API.
execute
(self, query, \*\*kwargs)Execute a given SQL statement and return results.
Attributes
Presto API host obtained from
TD_PRESTO_API
env variable or inferred from Treasure Data REST API endpoint.User agent passed to a Presto connection.
-
__init__
(self, apikey, endpoint, database, header)[source] Initialize self. See help(type(self)) for accurate signature.
-
property
user_agent
¶ User agent passed to a Presto connection.
-
property
presto_api_host
¶ Presto API host obtained from
TD_PRESTO_API
env variable or inferred from Treasure Data REST API endpoint.
-
cursor
(self, **kwargs)[source]¶ Get cursor defined by DB-API.
- Parameters
- **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
, rather than using a direct connection established by theprestodb
package.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 itself
- Returns
- prestodb.dbapi.Cursor, or tdclient.cursor.Cursor