Table Admin API¶
After creating a Cluster
, you can
interact with individual tables, groups of tables or column families within
a table.
List Tables¶
If you want a comprehensive list of all existing tables in a cluster, make a
ListTables API request with
Cluster.list_tables()
:
tables = cluster.list_tables()
Table Factory¶
To create a Table
object:
table = cluster.table(table_id)
Even if this Table
already
has been created with the API, you’ll want this object to use as a
parent of a ColumnFamily
or Row
.
Create a new Table¶
After creating the table object, make a CreateTable API request
with create()
:
table.create()
If you would to initially split the table into several tablets (Tablets are similar to HBase regions):
table.create(initial_split_keys=['s1', 's2'])
Rename an existing Table¶
Though the RenameTable API request is listed in the service definition, requests to that method return:
BigtableTableService.RenameTable is not yet implemented
We have implemented rename()
but it will not work unless the backend supports the method.
List Column Families in a Table¶
Though there is no official method for retrieving column families associated with a table, the GetTable API method returns a table object with the names of the column families.
To retrieve the list of column families use
list_column_families()
:
column_families = table.list_column_families()
Note
Unfortunately the garbage collection rules used to create each column family are not returned in the GetTable response.
Column Family Factory¶
To create a
ColumnFamily
object:
column_family = table.column_family(column_family_id)
There is no real reason to use this factory unless you intend to create or delete a column family.
In addition, you can specify an optional gc_rule
(a
GarbageCollectionRule
or similar):
column_family = table.column_family(column_family_id,
gc_rule=gc_rule)
This rule helps the backend determine when and how to clean up old cells in the column family.
See the Column Families doc for more information about
GarbageCollectionRule
and related classes.
Create a new Column Family¶
After creating the column family object, make a CreateColumnFamily API
request with
ColumnFamily.create()
column_family.create()
Delete an existing Column Family¶
Make a DeleteColumnFamily API request with
ColumnFamily.delete()
column_family.delete()
Update an existing Column Family¶
Though the UpdateColumnFamily API request is listed in the service definition, requests to that method return:
BigtableTableService.UpdateColumnFamily is not yet implemented
We have implemented
ColumnFamily.update()
but it will not work unless the backend supports the method.