pytd.table.Table

class pytd.table.Table(client, database, table)[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, database, table)[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, database, table)[source]
property exists

Check if a configured table exists.

Return type:

bool

create(column_names=[], column_types=[])[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()[source]

Delete a table from Treasure Data.

import_dataframe(dataframe, writer, if_exists='error', **kwargs)[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.