Store

Standard Warehouse

Create Manager

from terrene.store import StandardWarehouseManager

manager = StandardWarehouseManager(credentials=credentials, workspace=workspace)

Create

warehouse = manager.create(
    name='my warehouse', description='a short description about my warehouse')

Get

warehouse = mananger.get('uuid')

Query

query_params = {
    'workspace__object_id': '',
    'name': '',
    'description': '',
    'workspace__name': '',
    'workspace__owners__object_id': '',
    'workspace__owners__email': '',
    'workspace__contributors__object_id': '',
    'workspace__contributors__email': ''
}
warehouses = manger.query(query_params)

Update

warehouse.name = 'new name'
warehouse.save()

Create a Table

warehouse.create_table('mytable')

Drop a Table

warehouse.drop_table('mytable')

Read Rows

warehouse.read_rows(table='mytable', query='', select='')

The query should be in the LINQ Query format and select should contain a comma separated list of attribute names. Learn More

Write Row

warehouse.write_row({'attr1': 1, 'attr2': 'hello world'})

Delete a Warehouse

warehouse.delete()

SQL Database

Create a Manager

from terrene.store import SQLDatabaseManager

manager = SQLDatabaseManager(credentials=credentials, workspace=workspace)

Connect a New Database

warehouse = manager.create(
    name='my db', description='a short description about my db',
    connection_string='dialect+driver://username:[email protected]:port/database')

Example Connection Strings:

Get

warehouse = mananger.get('uuid')

Query

query_params = {
    'workspace__object_id': '',
    'name': '',
    'description': '',
    'workspace__name': '',
    'workspace__owners__object_id': '',
    'workspace__owners__email': '',
    'workspace__contributors__object_id': '',
    'workspace__contributors__email': ''
}
warehouses = manger.query(query_params)

Update

warehouse.name = 'new name'
warehouse.save()

Read Rows

warehouse.read_rows(query='SELECT * FROM USERS;')

Read a Row

warehouse.read_row(table='mytable', key='pk')

The query should be a SQL query supported by your database.

Delete

warehouse.delete()