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:
- database
Database name.
- Type:
str
- table
Table name.
- Type:
str
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
Check if a configured table exists.
- 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
andcolumn_types
are given, table is created by a Presto query with the specified schema.- Parameters:
column_names (list of str, optional) – Column names.
column_types (list of str, optional) – Column types corresponding to the names. Note that Treasure Data supports limited amount of types as documented in: https://docs.treasuredata.com/display/public/PD/Schema+Management
- 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.