pytd.table.Table

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

A table controller module.

Parameters
clientpytd.Client

Treasure Data client.

databasestring

Database name.

tablestring

Table name.

__init__(self, client, database, table)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(self, client, database, table)

Initialize self.

create(self[, column_names, column_types])

Create a table named as configured.

delete(self)

Delete a table from Treasure Data.

import_dataframe(self, dataframe, writer[, …])

Import a given DataFrame to a Treasure Data table.

Attributes

exist

Check if a configured table exists.

__init__(self, client, database, table)[source]

Initialize self. See help(type(self)) for accurate signature.

property exist

Check if a configured table exists.

Returns
boolean
create(self, 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
column_nameslist of string, optional

Column names.

column_typeslist of string, optional

Column types corresponding to the names. Note that Treasure Data supports limited amount of types as documented in: https://support.treasuredata.com/hc/en-us/articles/360001266468-Schema-Management

delete(self)[source]

Delete a table from Treasure Data.

import_dataframe(self, dataframe, writer, if_exists='error', **kwargs)[source]

Import a given DataFrame to a Treasure Data table.

Parameters
dataframepandas.DataFrame

Data loaded to a target table.

writerstring, {‘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{‘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.