Table
The Table module provides functionality for working with tables.
- class TableRow(table, data={})[source]
Bases:
Base- Parameters:
table (Table)
data (Dict | None)
- __init__(table, data={})[source]
Constructs all the necessary attributes for the TableRow object.
- Parameters:
table (Table) – The table that the row belongs to.
data (Dict, optional) – The data of the field.
- __repr__()[source]
Return a string representation of the TableRow.
- Returns:
The string representation of the TableRow.
- Return type:
str
- __getattr__(name)[source]
Get an attribute from the resource.
- Parameters:
name (str) – The name of the attribute
- Return type:
Any
- classmethod create_row(table, **kwargs)[source]
Create a new row in the table.
- Each keyword argument represents a field value for the row, where:
The keyword is the field name
The value is the field value
- Parameters:
table (Table) – table instance
- Keyword Arguments:
**kwargs – Arbitrary field values matching the table schema.
- Returns:
created table row instance
- Return type:
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table, TableRow >>> client = GeoboxClient() >>> table = client.get_table(uuid="12345678-1234-5678-1234-567812345678") or >>> table = Table.get_table(client, uuid="12345678-1234-5678-1234-567812345678") >>> row_data = { 'field1': 'value1' } >>> row = TableRow.create_row(table, row_data)
- classmethod get_row(table, row_id, user_id)[source]
Get a row by its id
- Parameters:
table (Table) – the table instance
row_id (int) – the row id
user_id (int, optional) – specific user. privileges required.
- Returns:
the table row instance
- Return type:
TanbleRow
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table, TableRow >>> client = GeoboxClient() >>> table = client.get_table(uuid="12345678-1234-5678-1234-567812345678") or >>> table = Table.get_table(client, uuid="12345678-1234-5678-1234-567812345678")
>>> row = TableRow.get_row(table, row_id=1)
- update(**kwargs)[source]
Update a row
- Keyword Arguments:
update (fields to)
- Returns:
updated row data
- Return type:
Dict
Example
>>> from geobox import GeoboxClient >>> client = GeoboxClient() >>> table = client.get_table(uuid="12345678-1234-5678-1234-567812345678") >>> row = table.get_row(row_id=1) >>> row.update(field1='new_value')
- delete()[source]
Delete a row
- Returns:
None
- Return type:
None
Example
>>> from geobox import GeoboxClient >>> client = GeoboxClient() >>> table = client.get_table(uuid="12345678-1234-5678-1234-567812345678") >>> row = table.get_row(row_id=1) >>> row.delete()
- _get_other_side_of_relationship(relationship)[source]
Determine which side of a relationship this table is on and return the opposite side.
Used internally to navigate bidirectional relationships.
- Parameters:
relationship (Relationship) – The relationship to examine.
- Returns:
The endpoint (table or layer) on the opposite side of the relationship from this table.
- Return type:
- Raises:
ValueError – If this table is not part of the given relationship.
Note
This method assumes the table is either the source or target, not the relation table in Many-to-Many relationships.
Fetch related rows/features from a relationship target.
Internal helper that dispatches to the appropriate API method based on target type.
- Parameters:
target (Table | VectorLayer) – The target endpoint (Table or VectorLayer) to query.
relationship_uuid (str) – UUID of the relationship to traverse.
- Raises:
TypeError – If target is not a Table or VectorLayer.
- Returns:
Related rows or features.
- Return type:
Get the related records on the other side of the relationship that are linked to this row
- Parameters:
relationship_uuid (str) – The uuid of relationship
- Returns:
a list of the related records
- Return type:
- Raises:
ValueError – If the given relationship does not involve the current table (i.e., this row is neither the source nor the target of the relationship).
TypeError – If the relationship target type is not supported for fetching related records.
Example
>>> from geobox import GeoboxClient >>> client = GeoboxClient() >>> table = client.get_table(uuid="12345678-1234-5678-1234-567812345678") >>> row = table.get_row(row_id=1) >>> related_records = row.get_related_records(relationship_uuid="12345678-1234-5678-1234-567812345678")
- associate_with(relationship_uuid, *, target_ids=None, q=None)[source]
Create relationships between the source record and target records
- Parameters:
relationship_uuid (str) – the relationship uuid
target_ids (List[int], optional) – a list of target record ids to be associated with the current record
q (str, optional) – query filter on target layer or table to select which target features or rows that are going to be related to the current record
- Returns:
the record association result
- Return type:
Dict
Example
>>> from geobox import GeoboxClient >>> client = GeoboxClient() >>> table = client.get_table(uuid="12345678-1234-5678-1234-567812345678") >>> row = table.get_row(row_id=1) >>> row.associate_with( ... relationship_uuid="12345678-1234-5678-1234-567812345678", ... target_ids=[1, 2, 3], ... )
- disassociate_with(relationship_uuid, *, target_ids=None, q=None)[source]
Remove relationships between the source record and target records
- Parameters:
relationship_uuid (str) – the relationship uuid
target_ids (List[int], optional) – a list of target record ids to be disassociated with the current record
q (str, optional) – query filter on target layer or table to select which target features or rows that are going to be related to the current
- Returns:
the record disassociation result
- Return type:
Dict
Example
>>> from geobox import GeoboxClient >>> client = GeoboxClient() >>> table = client.get_table(uuid="12345678-1234-5678-1234-567812345678") >>> row = table.get_row(row_id=1) >>> row.disassociate_with( ... relationship_uuid="12345678-1234-5678-1234-567812345678", ... target_ids=[1, 2, 3], ... )
- class TableField(table, data_type, field_id=None, data={})[source]
Bases:
Base- __init__(table, data_type, field_id=None, data={})[source]
Constructs all the necessary attributes for the Field object.
- __repr__()[source]
Return a string representation of the field.
- Returns:
The string representation of the field.
- Return type:
str
- __getattr__(name)[source]
Get an attribute from the resource.
- Parameters:
name (str) – The name of the attribute
- Return type:
Any
- property domain: Dict
Domain property
- Returns:
domain data
- Return type:
Dict
- classmethod create_field(table, name, data_type, data={})[source]
Create a new field
- Parameters:
- Returns:
the created field object
- Return type:
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> from geobox.field import Field >>> client = GeoboxClient() >>> table = client.get_table(uuid="12345678-1234-5678-1234-567812345678") >>> field = Field.create_field(client, table=table, name='test', data_type=FieldType.Integer)
- delete()[source]
Delete the field.
- Returns:
None
- Return type:
None
Example
>>> from geobox import GeoboxClient >>> from geobox.field import TableField >>> client = GeoboxClient() >>> table = client.get_table(uuid="12345678-1234-5678-1234-567812345678") >>> field = table.get_field(name='test') >>> field.delete()
- update(**kwargs)[source]
Update the field.
- Keyword Arguments:
name (str) – The name of the field.
display_name (str) – The display name of the field.
description (str) – The description of the field.
domain (Dict) – the domain of the field
hyperlink (bool) – the hyperlink field.
- Returns:
The updated data.
- Return type:
Dict
Example
>>> from geobox import GeoboxClient >>> from geobox.field import TableField >>> client = GeoboxClient() >>> table = client.get_table(uuid="12345678-1234-5678-1234-567812345678") >>> field = table.get_field(name='test') >>> field.update(name="my_field", display_name="My Field", description="My Field Description")
- update_domain(range_domain=None, list_domain=None)[source]
Update field domian values
- Parameters:
range_domain (Dict) – a dictionary with min and max keys.
list_domain (Dict) – a dictionary containing the domain codes and values.
- Returns:
the updated field domain
- Return type:
Dict
Example
>>> from geobox import GeoboxClient >>> client = GeoboxClient() >>> field = client.get_table(uuid="12345678-1234-5678-1234-567812345678").get_fields()[0] >>> range_d = {'min': 1, 'max': 10} >>> field.update_domain(range_domain = range_d) or >>> list_d = {'1': 'value1', '2': 'value2'} >>> field.update_domain(list_domain=list_d)
- add_index()[source]
Add an index to a field for better query performance
- Returns:
updated field data
- Return type:
Dict
Example
>>> from geobox import GeoboxClient >>> client = GeoboxClient() >>> field = client.get_table(uuid="12345678-1234-5678-1234-567812345678").get_fields()[0] >>> field.add_index()
- class Table(api, uuid, data={})[source]
Bases:
Base- Parameters:
api (GeoboxClient)
uuid (str)
data (Dict | None)
- BASE_ENDPOINT = 'tables/'
- __init__(api, uuid, data={})[source]
Initialize a table instance.
- Parameters:
api (GeoboxClient) – The GeoboxClient instance for making requests.
uuid (str) – The unique identifier for the table.
data (Dict) – The response data of the table.
- classmethod get_tables(api, **kwargs)[source]
Get a list of tables with optional filtering and pagination.
- Parameters:
api (GeoboxClient) – The GeoboxClient instance for making requests.
- Keyword Arguments:
include_settings (bool) – Whether to include table settings. default: False
temporary (bool) – Whether to return temporary tables. default: False
q (str) – query filter based on OGC CQL standard. e.g. “field1 LIKE ‘%GIS%’ AND created_at > ‘2021-01-01’”
search (str) – search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored
search_fields (str) – comma separated list of fields for searching
order_by (str) – comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: “A” denotes ascending order and “D” denotes descending order.
return_count (bool) – Whether to return total count. default: False.
skip (int) – Number of items to skip. default: 0
limit (int) – Number of items to return. default: 10
user_id (int) – Specific user. privileges required
shared (bool) – Whether to return shared tables. default: False
- Returns:
A list of table instances or the total number of tables.
- Return type:
List[Table] | int
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> tables = client.get_tables(q="name LIKE '%My table%'") or >>> tables = Table.get_tables(client, q="name LIKE '%My table%'")
- classmethod create_table(api, name, display_name=None, description=None, temporary=False, fields=None)[source]
Create a new table.
- Parameters:
api (GeoboxClient) – The GeoboxClient instance for making requests.
name (str) – The name of the Table.
display_name (str, optional) – The display name of the table.
description (str, optional) – The description of the table.
temporary (bool, optional) – Whether to create a temporary tables. default: False
fields (List[Dict], optional) – raw table fields. you can use create_field method for simpler and safer field addition. required dictionary keys: name, datatype
- Returns:
The newly created table instance.
- Return type:
- Raises:
ValidationError – If the table data is invalid.
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = client.create_table(name="my_table") or >>> table = Table.create_table(client, name="my_table")
- classmethod get_table(api, uuid, user_id=None)[source]
Get a table by UUID.
- Parameters:
api (GeoboxClient) – The GeoboxClient instance for making requests.
uuid (str) – The UUID of the table to get.
user_id (int) – Specific user. privileges required.
- Returns:
The Table object.
- Return type:
- Raises:
NotFoundError – If the table with the specified UUID is not found.
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = client.get_table(uuid="12345678-1234-5678-1234-567812345678") or >>> table = Table.get_table(client, uuid="12345678-1234-5678-1234-567812345678")
- classmethod get_table_by_name(api, name, user_id=None)[source]
Get a table by name
- Parameters:
api (GeoboxClient) – The GeoboxClient instance for making requests.
name (str) – the name of the table to get
user_id (int, optional) – specific user. privileges required.
- Returns:
returns the table if a table matches the given name, else None
- Return type:
Table | None
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = client.get_table_by_name(name='test') or >>> table = Table.get_table_by_name(client, name='test')
- update(**kwargs)[source]
Update the table.
- Keyword Arguments:
name (str) – The name of the table.
display_name (str) – The display name of the table.
description (str) – The description of the table.
- Returns:
The updated table data.
- Return type:
Dict
- Raises:
ValidationError – If the table data is invalid.
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = Table.get_table(client, uuid="12345678-1234-5678-1234-567812345678") >>> table.update(display_name="New Display Name")
- delete()[source]
Delete the Table.
- Returns:
None
- Return type:
None
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = Table.get_table(client, uuid="12345678-1234-5678-1234-567812345678") >>> table.delete()
- property settings: Dict
Get the table’s settings.
- Returns:
The table settings.
- Return type:
Dict
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = Table.get_table(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> setting = table.setting
- update_settings(settings)[source]
Update the settings
settings (Dict): settings dictionary
- Returns:
updated settings
- Return type:
Dict
- Parameters:
settings (Dict)
Example
>>> from geobox import GeoboxClient >>> client = GeoboxClient() >>> table1 = client.get_table(uuid="12345678-1234-5678-1234-567812345678") >>> table2 = client.get_table(uuid="12345678-1234-5678-1234-567812345678") >>> table1.update_settings(table2.settings)
- get_fields()[source]
Get all fields of the table.
- Returns:
A list of Field instances representing the table’s fields.
- Return type:
List[TableField]
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = Table.get_table(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> fields = table.get_fields()
- get_field(field_id)[source]
Get a specific field by ID.
- Parameters:
field_id (int, optional) – The ID of the field to retrieve.
- Returns:
The requested field instance.
- Return type:
- Raises:
NotFoundError – If the field with the specified ID is not found.
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = Table.get_table(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> field = table.get_field(field_id=1)
- get_field_by_name(name)[source]
Get a specific field by name.
- Parameters:
name (str) – The name of the field to retrieve.
- Returns:
The requested field instance.
- Return type:
- Raises:
NotFoundError – If the field with the specified name is not found.
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = Table.get_table(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> field = table.get_field_by_name(name='test')
- add_field(name, data_type, data={})[source]
Add a new field to the table.
- Parameters:
name (str) – The name of the new field.
data_type (FieldType) – The data type of the new field.
data (Dict, optional) – Additional field properties (display_name, description, etc.).
- Returns:
The newly created field instance.
- Return type:
- Raises:
ValidationError – If the field data is invalid.
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = Table.get_table(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> field = table.add_field(name="new_field", data_type=FieldType.String)
- calculate_field(target_field, expression, q=None, search=None, search_fields=None, row_ids=None, run_async=True, user_id=None)[source]
Calculate values for a field based on an expression.
- Parameters:
target_field (str) – The field to calculate values for.
expression (str) – The expression to use for calculation.
q (str, optional) – Query to filter features. default: None.
search (str, optional) – search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value
search_fields (str, optional) – comma separated list of fields for searching
row_ids (str, optional) – List of specific row IDs to include. default: None
run_async (bool, optional) – Whether to run the calculation asynchronously. default: True.
user_id (int, optional) – Specific user. privileges required.
- Returns:
The task instance of the calculation operation or the api response if the run_async=False.
- Return type:
Task | Dict
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = Table.get_table(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> task = table.calculate_field(target_field="target_field", ... expression="expression", ... q="name like 'my_layer'", ... row_ids=[1, 2, 3], ... run_async=True)
- get_rows(**kwargs)[source]
Query rows of a table
- Keyword Arguments:
relationship_uuid (str) – The uuid of relationship
related_record_id (int) – This is the id of the feature/row that these rows are related to. This id belongs to the related layer/table not this table
q (str) – Advanced filtering expression, e.g., ‘status = “active” and age > 20’
search (str) – Search term for keyword-based searching among fields/columns
search_fields (str) – Comma separated column names to search in
row_ids (str) – Comma separated list of row ids to filter for
fields (str) – Comma separated column names to include in results, or [ALL]
exclude (str) – Comma separated column names to exclude from result
order_by (str) – Comma separated list for ordering, e.g., ‘name A, id D’
skip (int) – Number of records to skip for pagination. default: 0
limit (int) – Maximum number of records to return. default: 100
return_count (bool) – If true, returns only the count of matching rows
user_id (int) – Specific user. privileges required
- Returns:
list of table rows objects
- Return type:
List[TableRow]
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = client.get_table(uuid="12345678-1234-5678-1234-567812345678") or >>> table = Table.get_table(client, uuid="12345678-1234-5678-1234-567812345678")
>>> rows = table.get_rows()
- get_row(row_id, user_id=None)[source]
Get a row by its id
- Parameters:
row_id (int) – the row id
user_id (int, optional) – specific user. privileges required.
- Returns:
the table row instance
- Return type:
TanbleRow
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = client.get_table(uuid="12345678-1234-5678-1234-567812345678") or >>> table = Table.get_table(client, uuid="12345678-1234-5678-1234-567812345678")
>>> row = table.get_row(row_id=1)
- create_row(**kwargs)[source]
Create a new row in the table.
- Each keyword argument represents a field value for the row, where:
The keyword is the field name
The value is the field value
- Keyword Arguments:
**kwargs – Arbitrary field values matching the table schema.
- Returns:
created table row instance
- Return type:
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = client.get_table(uuid="12345678-1234-5678-1234-567812345678") or >>> table = Table.get_table(client, uuid="12345678-1234-5678-1234-567812345678")
>>> row = table.create_row( ... field1=value1 ... )
- import_rows(file, *, file_encoding='utf-8', input_dataset=None, delimiter=',', has_header=True, report_errors=False, bulk_insert=True)[source]
Import rows from a CSV file into a table
- Parameters:
file (File) – file object to import.
file_encoding (str, optional) – Character encoding of the input file. default: utf-8
input_dataset (str, optional) – Name of the dataset in the input file.
delimiter (str, optional) – the delimiter of the dataset. default: ,
has_header (bool, optional) – Whether the file has header or not. default: True
report_errors (bool, optional) – Whether to report import errors. default: False
bulk_insert (bool, optional)
- Returns:
The task instance of the import operation.
- Return type:
- Raises:
ValidationError – If the import parameters are invalid.
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = Table.get_table(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> file = client.get_file(uuid="12345678-1234-5678-1234-567812345678") >>> task = table.import_rows( ... file=file, ... )
- export_rows(out_filename, *, out_format=TableExportFormat.CSV, q=None, search=None, search_fields=None, row_ids=None, fields=None, exclude=None, order_by=None, zipped=False, run_async=True)[source]
Export rows of a table to a file
- Parameters:
out_filename (str) – Name of the output file without the format (.csv)
out_format (TableExportFormat, optional) – Format of the output file
q (str, optional) – query filter based on OGC CQL standard. e.g. “field1 LIKE ‘%GIS%’ AND created_at > ‘2021-01-01’”
search (str, optional) – search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value
search_fields (str, optional) – comma separated list of fields for searching
row_ids (str, optional) – List of specific row IDs to include
fields (str, optional) – List of specific field names to include
exclude (str, optional) – List of specific field names to exclude
order_by (str, optional) – comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: “A” denotes ascending order and “D” denotes descending order.
zipped (str, optional) – Whether to compress the output file
run_async (bool, optional) – Whether to run the export asynchronously. default: True
- Returns:
The task instance of the export operation (run_async=True) or the export result (run_async=False)
- Return type:
Task | Dict
- Raises:
ValidationError – If the export parameters are invalid.
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = Table.get_table(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> file = client.get_file(uuid="12345678-1234-5678-1234-567812345678") >>> task = table.export_rows( ... file=file, ... )
Shares the table with specified users.
- Parameters:
users (List[User]) – The list of user objects to share the table with.
- Returns:
None
- Return type:
None
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = Table.get_table(client, uuid="12345678-1234-5678-1234-567812345678") >>> users = client.search_users(search='John') >>> table.share(users=users)
Unshares the table with specified users.
- Parameters:
users (List[User]) – The list of user objects to unshare the table with.
- Returns:
None
- Return type:
None
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = Table.get_table(client, uuid="12345678-1234-5678-1234-567812345678") >>> users = client.search_users(search='John') >>> table.unshare(users=users)
Retrieves the list of users the table is shared with.
- Parameters:
search (str, optional) – The search query.
skip (int, optional) – The number of users to skip.
limit (int, optional) – The maximum number of users to retrieve.
- Returns:
The list of shared users.
- Return type:
List[User]
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = Table.get_table(client, uuid="12345678-1234-5678-1234-567812345678") >>> table.get_shared_users(search='John', skip=0, limit=10)
- get_relations()[source]
Get the relationships that include this table
- Returns:
list of the relationships
- Return type:
List[Relationship]
Example
>>> from geobox import GeoboxClient >>> from geobox.table import Table >>> client = GeoboxClient() >>> table = client.get_table(uuid="12345678-1234-5678-1234-567812345678") or >>> table = Table.get_table(client, uuid="12345678-1234-5678-1234-567812345678") >>> relationships = table.get_relations()