:orphan: :py:mod:`thanosql.resources._table` =================================== .. py:module:: thanosql.resources._table Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: thanosql.resources._table.BaseColumn thanosql.resources._table.Column thanosql.resources._table.Unique thanosql.resources._table.PrimaryKey thanosql.resources._table.ForeignKey thanosql.resources._table.Constraints thanosql.resources._table.BaseTable thanosql.resources._table.TableObject thanosql.resources._table.IfExists thanosql.resources._table.TableService thanosql.resources._table.OnConflict thanosql.resources._table.Table thanosql.resources._table.TableTemplate thanosql.resources._table.TableTemplateService .. py:class:: BaseColumn(/, **data: Any) Bases: :py:obj:`thanosql.resources._model.BaseModel` Usage docs: https://docs.pydantic.dev/2.9/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __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. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: default :type: Optional[str] .. py:attribute:: is_nullable :type: Optional[bool] :value: True .. py:attribute:: type :type: str .. py:attribute:: name :type: str .. py:class:: Column(/, **data: Any) Bases: :py:obj:`thanosql.resources._model.BaseModel` Usage docs: https://docs.pydantic.dev/2.9/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __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. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: id :type: Optional[int] .. py:attribute:: default :type: Optional[str] .. py:attribute:: is_nullable :type: Optional[bool] :value: True .. py:attribute:: type :type: str .. py:attribute:: name :type: str .. py:class:: Unique(/, **data: Any) Bases: :py:obj:`thanosql.resources._model.BaseModel` Usage docs: https://docs.pydantic.dev/2.9/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __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. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: name :type: Optional[str] .. py:attribute:: columns :type: Optional[List[str]] :value: [] .. py:class:: PrimaryKey(/, **data: Any) Bases: :py:obj:`thanosql.resources._model.BaseModel` Usage docs: https://docs.pydantic.dev/2.9/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __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. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: name :type: Optional[str] .. py:attribute:: columns :type: Optional[List[str]] :value: [] .. py:class:: ForeignKey(/, **data: Any) Bases: :py:obj:`thanosql.resources._model.BaseModel` Usage docs: https://docs.pydantic.dev/2.9/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __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. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: name :type: Optional[str] .. py:attribute:: reference_schema :type: str :value: 'public' .. py:attribute:: reference_column :type: str .. py:attribute:: reference_table :type: str .. py:attribute:: column :type: str .. py:class:: Constraints(/, **data: Any) Bases: :py:obj:`thanosql.resources._model.BaseModel` Usage docs: https://docs.pydantic.dev/2.9/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __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. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: unique :type: Optional[List[Unique]] .. py:attribute:: primary_key :type: Optional[PrimaryKey] .. py:attribute:: foreign_keys :type: Optional[List[ForeignKey]] .. py:class:: BaseTable(/, **data: Any) Bases: :py:obj:`thanosql.resources._model.BaseModel` Usage docs: https://docs.pydantic.dev/2.9/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __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. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: name :type: Optional[str] .. py:attribute:: table_schema :type: Optional[str] .. py:attribute:: columns :type: Optional[List[BaseColumn]] .. py:attribute:: constraints :type: Optional[Constraints] .. py:class:: TableObject(/, **data: Any) Bases: :py:obj:`thanosql.resources._model.BaseModel` Usage docs: https://docs.pydantic.dev/2.9/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __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. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: columns :type: Optional[List[BaseColumn]] .. py:attribute:: constraints :type: Optional[Constraints] .. py:class:: IfExists(*args, **kwds) Bases: :py:obj:`enum.Enum` Create a collection of name/value pairs. Example enumeration: >>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3 Access them by: - attribute access: >>> Color.RED - value lookup: >>> Color(1) - name lookup: >>> Color['RED'] Enumerations can be iterated over, and know how many members they have: >>> len(Color) 3 >>> list(Color) [, , ] Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details. .. py:attribute:: FAIL :value: 'fail' .. py:attribute:: APPEND :value: 'append' .. py:attribute:: REPLACE :value: 'replace' .. py:class:: TableService(client: thanosql._client.ThanoSQL) Bases: :py:obj:`thanosql._service.ThanoSQLService` Service layer for table methods. .. attribute:: client The ThanoSQL client used to make requests to the engine. :type: ThanoSQL .. attribute:: template The table template service layer to access methods involving table templates. :type: TableTemplateService .. py:method:: list(schema: Optional[str] = None, verbose: Optional[bool] = None, offset: Optional[int] = None, limit: Optional[int] = None) -> List[Table] Lists tables stored in the workspace. :param schema: The schema where the listed tables should reside in. If not set, all tables from all schemas will be included. :type schema: str, optional :param verbose: Whether to include the table columns and constraints in the results. By default, or if set to False, only retrieves the names and schemas of stored tables. :type verbose: bool, optional :param offset: When set to n, skips the first n results and excludes them from the output list. Otherwise, starts the list from the first result stored. Must be greater than 0. :type offset: int, optional :param limit: When set to n, limits the number of results listed to n. Otherwise, lists up to 100 results per call. Must range between 0 to 100. :type limit: int, optional :returns: A list of Table objects. :rtype: List[Table] :raises ThanoSQLValueError: If offset is less than 0 or if limit is not between 0 to 100 (inclusive). .. py:method:: get(name: str, schema: Optional[str] = None) -> Table Shows the details of the specified table. :param name: The name of the table to be retrieved. :type name: str :param schema: The schema where the table to be retrieved is in. If not specified, this method will look for the table in "public". :type schema: str, optional :returns: A Table object. :rtype: Table .. py:method:: update(name: str, schema: Optional[str] = None, table: Optional[BaseTable] = None) -> Table Updates the specified table. :param name: The name of the table to be updated. :type name: str :param schema: The schema where the table to be updated is in. If not specified, this method will look for the table in "public". :type schema: str, optional :param table: BaseTable object containing changed details of the table to be updated. Any attribute of BaseTable can be modified, and if left unset, the current value will be maintained after update. The attributes are as follows: - name: new name to rename the table to - schema: new schema to move the table to - columns: new columns of the updated table. All new columns must be in this object, including columns that already exist in the original table. If this attribute is set but some original columns are not included, they will be removed from the table. - constraints: new constraints of the updated table. All new constraints must be in this object, including constraints that already exist in the original table. If this attribute is set but some original constraints are not included, they will be removed from the table. :type table: BaseTable, optional :returns: Table object of the new table after update. :rtype: Table :raises ThanoSQLValueError: If the table object contains invalid formatting. .. py:method:: create(name: str, table: TableObject, schema: Optional[str] = None, if_not_exists: bool = False) -> Table Creates a new table. :param name: The name of the table to be created. :type name: str :param table: TableObject containing the columns and constraints of the table to be created. In order to create an empty table, pass in an empty object (TableObject()). :type table: TableObject :param schema: The schema to save the created table in. If not specified, the table will be saved to "public". :type schema: str, optional :param if_not_exists: Whether to throw an error if a table of the same name already exists. When set to False (default), an error will be shown. When True, the table will only be created if it does not exist already. Otherwise, do nothing. :type if_not_exists: bool, default False :returns: Table object of the created table. :rtype: Table :raises ThanoSQLValueError: If the table object contains invalid formatting. .. py:method:: upload(name: str, file: Optional[Union[str, os.PathLike]] = None, df: Optional[pandas.DataFrame] = None, schema: Optional[str] = None, table: Optional[TableObject] = None, if_exists: str = 'fail') -> Table Uploads the contents of a CSV or Excel-like file or Pandas DataFrame into the specified table. Either a CSV or Excel-like (.xls, .xlsx, .xlsm, .xlsb, .odf, .ods, .odt) file or DataFrame must be specified. However, both should not be used at the same time. Note: If you are working with a Strict Open XML Spreadsheet (*.xlsx) file, change it to Excel Workbook (*.xlsx), save it, and try using it again. :param name: The name of the table created from the file or DataFrame. :type name: str :param file: CSV or Excel-like file containing tabulated data to be uploaded to the specified table. :type file: str or PathLike, optional :param df: Pandas DataFrame containing data to be uploaded to the specified table. :type df: DataFrame, optional :param schema: The schema to save the created table in. If not specified, the table will be saved to "public". :type schema: str, optional :param table: TableObject containing the columns and constraints of the table to be created. If specified, the created table will follow the object format and no type inference is conducted. Otherwise, type inference will be performed and the table will be created to match the columns from source. :type table: TableObject, optional :param if_exists: What to do if table of the same name already exists. There are only three available values: - fail: fails (throws an error) if the same table exists - append: appends records into an existing table (columns must match in order to not make an error) - replace: deletes existing table and creates a new one with the given name :type if_exists: str, default "fail" :returns: Table object of the uploaded table. :rtype: Table :raises ThanoSQLValueError: - If if_exists is not one of "fail", "append", or "replace". - If neither file nor df is used, or if both are used at the same time. - If file is used but it is neither CSV nor Excel-like. - If the file or df contains badly-formatted contents. - If a table body is specified but does not match the contents of the file or df. - If if_exists is set to "append" but the new contents does not match the format of the existing table. .. py:method:: delete(name: str, schema: Optional[str] = None) -> dict Deletes the specified table. :param name: The name of the table to be deleted. :type name: str :param schema: The schema where the table to be deleted is in. If not specified, this method will look for the table in "public". :type schema: str, optional :returns: A dictionary containing a success message, table name, and schema in the format of:: { "message": "string", "table_name": "string", "schema": "string" } :rtype: dict .. py:class:: OnConflict(*args, **kwds) Bases: :py:obj:`enum.Enum` Create a collection of name/value pairs. Example enumeration: >>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3 Access them by: - attribute access: >>> Color.RED - value lookup: >>> Color(1) - name lookup: >>> Color['RED'] Enumerations can be iterated over, and know how many members they have: >>> len(Color) 3 >>> list(Color) [, , ] Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details. .. py:attribute:: FAIL :value: 'fail' .. py:attribute:: SKIP :value: 'skip' .. py:class:: Table(/, **data: Any) Bases: :py:obj:`BaseTable` Extends the BaseTable class, which has name, schema, columns, and constraints as attributes, with a table service layer to allow connection to the ThanoSQL engine. .. py:attribute:: service :type: Optional[TableService] The table service layer to access the ThanoSQL client. .. py:method:: get_records(offset: Optional[int] = None, limit: Optional[int] = None) -> thanosql.resources._record.Records Lists the records of the table. :param offset: When set to n, skips the first n results and excludes them from the output list. Otherwise, starts the list from the first result stored. Must be greater than 0. :type offset: int, optional :param limit: When set to n, limits the number of results listed to n. Otherwise, lists up to 100 results per call. Must range between 0 to 100. :type limit: int, optional :returns: A Records object. :rtype: Records :raises ThanoSQLValueError: If offset is less than 0 or if limit is not between 0 to 100 (inclusive). .. py:method:: get_records_as_csv(timezone_offset: Optional[int] = None) -> None Downloads the records of the table as a CSV file. :param timezone_offset: Timezone offset from Coordinated Universal Time (UTC). If not set, this value is 9, following the timezone in Seoul. This value is used to determine the time used in the file name. :type timezone_offset: int, optional .. py:method:: insert(records: List[dict], on_conflict: str = 'fail') -> Table Inserts records to the specified table. :param records: The records to be inserted in the format of a list of column-value pairs. :type records: list of dict :param on_conflict: What to do when conflict(s) due to unique constraint violation happen(s). There are only two available values: - fail: fails (throws an error) if any of the record violates the target table's unique constraint(s) - skip: skips record(s) that violate(s) unique constraint(s) and insert the rest :type on_conflict: str, default "fail" :returns: A Table object. :rtype: Table :raises ThanoSQLValueError: - If on_conflict is not one of "fail" or "skip". - If the records are in an invalid format or contain invalid contents. .. py:class:: TableTemplate(/, **data: Any) Bases: :py:obj:`thanosql.resources._model.BaseModel` Usage docs: https://docs.pydantic.dev/2.9/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __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. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: name :type: str .. py:attribute:: table_template :type: TableObject .. py:attribute:: version :type: Optional[str] .. py:attribute:: compatibility :type: Optional[str] .. py:attribute:: created_at :type: Optional[datetime.datetime] .. py:class:: TableTemplateService(client: thanosql._client.ThanoSQL) Bases: :py:obj:`thanosql._service.ThanoSQLService` Service layer for table template methods. .. attribute:: client The ThanoSQL client used to make requests to the engine. :type: ThanoSQL .. py:method:: list(search: Optional[str] = None, order_by: Optional[str] = None, latest: Optional[bool] = None) -> List[TableTemplate] Lists table templates in the workspace. :param search: Search keywords that the table template names in the results must contain. If not set, all table templates are returned by default. :type search: str, optional :param order_by: How to order the results. There are only three possible values: - recent: based on the date of creation, from most recent to oldest - name_asc: based on the name of the template, from A to Z - name_desc: based on the name of the template, from Z to A :type order_by: str, optional :param latest: Whether to return only the latest version of each table template. By default, or if set to False, all versions of table templates are included in the results. :type latest: bool, optional :returns: A list of TableTemplate objects. :rtype: List[TableTemplate] :raises ThanoSQLValueError: If order_by is not one of "recent", "name_asc", or "name_desc". .. py:method:: get(name: str, version: Optional[str] = None) -> dict Shows the details of the specified table template. :param name: The name of the table template to be retrieved. :type name: str :param version: The version of the table template to be retrieved. The value can either be a specific version such as "1.0", or "latest". If "latest" is specified, only the latest version of the table template will be shown. If version is not set, all versions will be shown. :type version: str, optional :returns: A dictionary of matching table template(s) in the format of:: { "table_templates": ["TableTemplate"], "versions": ["string"] } :rtype: dict .. py:method:: create(name: str, table_template: TableObject, version: Optional[str] = None, compatibility: Optional[str] = None) -> TableTemplate Creates a new table template. :param name: The name of the table template to be created. :type name: str :param table_template: TableObject containing the columns and constraints of the table template to be created. In order to create an empty table template, pass in an empty object (TableObject()). :type table_template: TableObject :param version: The version of the table template to be created. It must be in the format of "[1-9].[0-9]". If not set, it will default to "1.0". :type version: str, optional :param compatibility: The compatibility setting of the table template to be created. If not set, it will default to "ignore" (no compatibility checks). :type compatibility: str, optional :returns: TableTemplate object of the created table template. :rtype: TableTemplate :raises ThanoSQLValueError: - If the template name contains invalid characters or is too long. - If version is specified but is not in the right format. - If the table template contains formatting errors. .. py:method:: delete(name: str, version: Optional[str] = None) -> dict Deletes the specified table template. :param name: The name of the table template to be removed. :type name: str :param version: The version of the table template to be removed. If not specified, all versions of the table template will be removed. :type version: str, optional :returns: A dictionary containing a success message and the name of the table template in the format of:: { "message": "string", "table_template_name": "string" } :rtype: dict