pytd.table.Table

class pytd.table.Table(client: Client, database: str, table: str)[source]

A table controller module.

Parameters:
  • client (pytd.Client) – Treasure Data client.

  • database (str) – Database name.

  • table (str) – Table name.

client

Treasure Data client.

Type:

pytd.Client

database

Database name.

Type:

str

table

Table name.

Type:

str

__init__(client: Client, database: str, table: str) None[source]

Methods

__init__(client, database, table)

create([column_names, column_types])

Create a table named as configured.

delete()

Delete a table from Treasure Data.

import_dataframe(dataframe, writer[, if_exists])

Import a given DataFrame to a Treasure Data table.

Attributes

exists

Check if a configured table exists.

__init__(client: Client, database: str, table: str) None[source]
property exists: bool

Check if a configured table exists.

Return type:

bool

create(column_names: list[str] | None = None, column_types: list[str] | None = None) None[source]

Create a table named as configured.

When column_names and column_types are given, table is created by a Presto query with the specified schema.

Parameters:
delete() None[source]

Delete a table from Treasure Data.

import_dataframe(dataframe: DataFrame, writer: Literal['bulk_import', 'insert_into', 'spark'] | Writer, if_exists: Literal['error', 'overwrite', 'append', 'ignore'] = 'error', **kwargs: Any) None[source]

Import a given DataFrame to a Treasure Data table.

Parameters:
  • dataframe (pandas.DataFrame) – Data loaded to a target table.

  • writer (string, {‘bulk_import’, ‘insert_into’, ‘spark’}, or pytd.writer.Writer) – A Writer to choose writing method to Treasure Data. If string value, a temporal Writer instance will be created.

  • if_exists (str, {'error', 'overwrite', 'append', 'ignore'}, default: 'error') –

    What happens when a target table already exists.

    • error: raise an exception.

    • overwrite: drop it, recreate it, and insert data.

    • append: insert data. Create if does not exist.

    • ignore: do nothing.