Managing Schemas
This notebook shows how you can manage schemas with the ThanoSQL library. We will cover how to create schemas, get the list of stored schemas, and delete schemas. First, initialize a ThanoSQL client with your API token and engine URL.
from thanosql import ThanoSQL
client = ThanoSQL(
api_token="THANOSQL_API_TOKEN",
engine_url="THANOSQL_ENGINE_URL"
)
Listing Schemas
You can get the list of schemas in your workspace using the list() function. There are no required or optional parameters.
res = client.schema.list()
for schema in res["schemas"]:
print(schema["name"])
Creating Schemas
It is possible to create schemas through the ThanoSQL client. Only the schema name is needed.
client.schema.create("my_schema_1")
Deleting Schemas
Currently, there is no direct API for deleting schemas. However, it is possible to do through raw query using the query API.
query = f"DROP SCHEMA my_schema_1 CASCADE"
client.query.execute(query)