Tables¶
You'll find below all the available methods to interact with the tables of a SeaTable base.
Global structure¶
Here is the global structure of a table object:
{
"_id": "IfcB",
"name": "New table",
"is_header_locked": false,
"summary_configs": {},
"columns": [ // (1)!
{
"key": "0000",
"type": "number",
"name": "First column",
"editable": true,
"width": 200,
"resizable": true,
"draggable": true,
"data": null,
"permission_type": "",
"permitted_users": []
},
{
"key": "2w6F",
"type": "text",
"name": "second column",
"editable": true,
"width": 200,
"resizable": true,
"draggable": true,
"data": null,
"permission_type": "",
"permitted_users": []
},
{
"key": "3aAf",
"type": "date",
"name": "third column",
"editable": true,
"width": 200,
"resizable": true,
"draggable": true,
"data": null,
"permission_type": "",
"permitted_users": []
}
],
"rows": [], // (2)!
"views": [ // (3)!
{
"_id": "0000",
"name": "Default View",
"type": "table",
"is_locked": false,
"filter_conjunction": "And",
"filters": [],
"sorts": [],
"groupbys": [],
"group_rows": [],
"groups": [],
"colorbys": {},
"hidden_columns": [],
"rows": [],
"formula_rows": {},
"link_rows": {},
"summaries": {},
"colors": {}
}
],
"id_row_map": {}
}
-
Array of existing columns
-
Array of existing rows
-
Array of existing views
Please refer to the SeaTable API Reference for a more detailed presentation.{ "_id": "0000", "name": "Default View", "type": "table", "is_locked": false, "rows": [], "formula_rows": {}, "summaries": [], "filter_conjunction": "And", "sorts": [], "filters": [], "hidden_columns": [], "groupbys": [], "group_rows": [], "groups": [] }
You can have a look at the specific view, column or row structure on the corresponding pages.
Retrieve table(s)¶
Get current table
There is no specific method to get the current (selected) table as it is a property from the context object, so simply use context.current_table.
list_tables
Get all tables of the current base.
__ Output__ List of table dictsExample
get_table_by_name
Get a table object by its name.
Output Single table dict (None if there is no table named table_name) Example
Add table¶
add_table
Add a table named table_name into a base. The columns argument is an optional list of column objects.
lang(optional): can been(default) for English orzh-cnfor Chinese and will determine the name of the firstNamecolumn (if nocolumnswhere specified)columns(optional): list of column objects describing the columns of the new table.
Output Single table dict (throws an error if a table named table_name already exists)
Example
Rename table¶
rename_table
Rename an existing table named table_name to new_table_name.
success key with the result of the operation (throws an error if no table named table_name exists) Example
Delete table¶
delete_table
Delete a table named tableName from the base. By the way, the table can be restored from the logs. Deleting the last table is not possible.
Output Dict containing a single success key with the result of the operation (throws an error if no table named table_name exists or if you try to delete the last table)
Example