DB API

tdclient

tdclient.Binary(string: bytes) bytes[source]
tdclient.DateFromTicks(ticks: float) date[source]
tdclient.TimeFromTicks(ticks: float) time[source]
tdclient.TimestampFromTicks(ticks: float) datetime[source]
tdclient.connect(*args: Any, **kwargs: Any) Connection[source]

Returns a DBAPI compatible connection object

Parameters:
  • type (str) – query engine type. “hive” by default.

  • db (str) – the name of database on Treasure Data

  • result_url (str) – result output URL

  • priority (str) – job priority

  • retry_limit (int) – job retry limit

  • wait_interval (int) – job wait interval to check status

  • wait_callback (callable) – a callback to be called on every ticks of job wait

Returns:

tdclient.connection.Connection

tdclient.connection

class tdclient.connection.Connection(type: str | None = None, db: str | None = None, result_url: str | None = None, priority: Literal[-2, -1, 0, 1, 2, 'VERY LOW', 'LOW', 'NORMAL', 'HIGH', 'VERY HIGH'] | None = None, retry_limit: int | None = None, wait_interval: int | None = None, wait_callback: Callable[[Cursor], None] | None = None, **kwargs: Any)[source]

Bases: object

close() None[source]
commit() None[source]
cursor() Cursor[source]
rollback() None[source]
property api: API

tdclient.cursor

class tdclient.cursor.Cursor(api: API, wait_interval: int = 5, wait_callback: Callable[[Cursor], None] | None = None, **kwargs: Any)[source]

Bases: object

callproc(procname: str, *parameters: Any) None[source]
close() None[source]
execute(query: str, args: dict[str, Any] | None = None) str | None[source]
executemany(operation: str, seq_of_parameters: list[dict[str, Any]]) list[str | None][source]
fetchall() list[Any][source]

Fetch all (remaining) rows of a query result, returning them as a sequence of sequences (e.g. a list of tuples). Note that the cursor’s arraysize attribute can affect the performance of this operation.

fetchmany(size: int | None = None) list[Any][source]

Fetch the next set of rows of a query result, returning a sequence of sequences (e.g. a list of tuples). An empty sequence is returned when no more rows are available.

fetchone() Any | None[source]

Fetch the next row of a query result set, returning a single sequence, or None when no more data is available.

job_result() list[dict[str, Any]][source]

Fetch job results

Returns:

Job result in list

job_status() str[source]

Show job status

Returns:

The status information of the given job id at last execution.

nextset() None[source]
setinputsizes(sizes: Any) None[source]
setoutputsize(size: Any, column: Any = None) None[source]
show_job() dict[str, Any][source]

Returns detailed information of a Job

Returns:

Detailed information of a job

Return type:

dict

property api: API
property description: list[Any]
property rowcount: int