thanosql.resources._view

Module Contents

Classes

View

Usage docs: https://docs.pydantic.dev/2.9/concepts/models/

ViewService

Service layer for view methods.

class thanosql.resources._view.View(/, **data: Any)[source]

Bases: thanosql.resources._model.BaseModel

Usage docs: https://docs.pydantic.dev/2.9/concepts/models/

A base class for creating Pydantic models.

__class_vars__

The names of the class variables defined on the model.

__private_attributes__

Metadata about the private attributes of the model.

__signature__

The synthesized __init__ [Signature][inspect.Signature] of the model.

__pydantic_complete__

Whether model building is completed, or if there are still undefined fields.

__pydantic_core_schema__

The core schema of the model.

__pydantic_custom_init__

Whether the model has a custom __init__ function.

__pydantic_decorators__

Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.

__pydantic_generic_metadata__

Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.

__pydantic_parent_namespace__

Parent namespace of the model, used for automatic rebuilding of models.

__pydantic_post_init__

The name of the post-init method for the model, if defined.

__pydantic_root_model__

Whether the model is a [RootModel][pydantic.root_model.RootModel].

__pydantic_serializer__

The pydantic-core SchemaSerializer used to dump instances of the model.

__pydantic_validator__

The pydantic-core SchemaValidator used to validate instances of the model.

__pydantic_extra__

A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’.

__pydantic_fields_set__

The names of fields explicitly set during instantiation.

__pydantic_private__

Values of private attributes set on the model instance.

name: str
table_schema: str | None
columns: List[thanosql.resources.Column] = []
definition: str = ''
class thanosql.resources._view.ViewService(client: thanosql._client.ThanoSQL)[source]

Bases: thanosql._service.ThanoSQLService

Service layer for view methods.

client

The ThanoSQL client used to make requests to the engine.

Type:

ThanoSQL

list(schema: str | None = None, verbose: bool | None = None, offset: int | None = None, limit: int | None = None) List[View][source]

Lists views stored in the workspace.

Parameters:
  • schema (str, optional) – When specified, lists views from a specific schema only. Otherwise, lists views from all available schemas.

  • verbose (bool, optional) – When not set or set to False (default behavior), only lists view names and the schema they belong to. When set to True, includes column descriptions and view definition in the output on top of the basic (name and schema) information.

  • offset (int, optional) – When set to n, skips the first n views and excludes them from the output list. Otherwise, starts the list from the first view stored. Must be greater than 0.

  • limit (int, optional) – When set to n, limits the number of views listed to n. Otherwise, lists up to 100 views per call. Must range between 0 to 100.

Returns:

A list of View objects.

Return type:

List[View]

Raises:

ThanoSQLValueError – If offset is less than 0 or if limit is not between 0 to 100 (inclusive).

get(name: str, schema: str | None = None) View[source]

Shows the details of the specified view.

Parameters:
  • name (str) – The name of the view to be retrieved.

  • schema (str, optional) – The schema the target view is stored in. When not specified, defaults to “public”.

Returns:

A View object.

Return type:

View

delete(name: str, schema: str | None = None) dict[source]

Deletes the specified view.

Parameters:
  • name (str) – The name of the view to be deleted.

  • schema (str, optional) – The schema the target view is stored in. When not specified, defaults to “public”.

Returns:

A dictionary containing a success message and the name of the deleted view in the format of:

{
    "message": "string",
    "view_name": "string"
}

Return type:

dict