FieldSpec#
- class lsst.daf.butler.ddl.FieldSpec(name: str, dtype: type, length: int | None = None, nbytes: int | None = None, primaryKey: bool = False, autoincrement: bool = False, nullable: bool = True, default: Any = None, doc: str | None = None)#
Bases:
objectA data class for defining a column in a logical
Registrytable.Attributes Summary
Whether the database should insert automatically incremented values when no value is provided in an INSERT.
A server-side default value for this field.
Documentation for this field.
Type of the column; usually a
typesubclass provided by SQLAlchemy that defines both a Python type and a corresponding precise SQL type.Length of the type in the database, for variable-length types.
Name of the column.
Natural length used for hash and encoded-region columns, to be converted into the post-encoding length.
Whether this field is allowed to be NULL.
Whether this field is (part of) its table's primary key.
Methods Summary
for_region([name, nullable, nbytes])Create a
FieldSpecfor a spatial region column.fromConfig(config, *args, **kwargs)Return the Python type associated with this field's (SQL) dtype.
Return a sized version of the column type.
Indicate that this is a sqlalchemy.String field spec.
Attributes Documentation
- autoincrement: bool = False#
Whether the database should insert automatically incremented values when no value is provided in an INSERT.
- default: Any = None#
A server-side default value for this field.
This is passed directly as the
server_defaultargument tosqlalchemy.schema.Column. It does _not_ go through SQLAlchemy’s usual type conversion or quoting for Python literals, and should hence be used with care. See the SQLAlchemy documentation for more information.
- doc: str | None = None#
Documentation for this field.
- dtype: type = <dataclasses._MISSING_TYPE object>#
Type of the column; usually a
typesubclass provided by SQLAlchemy that defines both a Python type and a corresponding precise SQL type.
- length: int | None = None#
Length of the type in the database, for variable-length types.
- name: str = <dataclasses._MISSING_TYPE object>#
Name of the column.
- nbytes: int | None = None#
Natural length used for hash and encoded-region columns, to be converted into the post-encoding length.
- nullable: bool = True#
Whether this field is allowed to be NULL. If
primaryKeyisTrue, during construction this value will be forced toFalse.
- primaryKey: bool = False#
Whether this field is (part of) its table’s primary key.
Methods Documentation
- classmethod for_region(name: str = 'region', nullable: bool = True, nbytes: int = 2048) FieldSpec#
Create a
FieldSpecfor a spatial region column.Parameters#
- name
str, optional Name for the field.
- nullable
bool, optional Whether NULL values are permitted.
- nbytes
int, optional Maximum number of bytes for serialized regions. The actual column size will be larger to allow for base-64 encoding.
Returns#
- spec
FieldSpec Specification structure for a region column.
- name
- getPythonType() type#
Return the Python type associated with this field’s (SQL) dtype.
Returns#
- type
type Python type associated with this field’s (SQL)
dtype.
- type
- getSizedColumnType() TypeEngine | type#
Return a sized version of the column type.
Utilizes either (or neither) of
self.lengthandself.nbytes.Returns#
- dtype
sqlalchemy.types.TypeEngine A SQLAlchemy column type object.
- dtype
- isStringType() bool#
Indicate that this is a sqlalchemy.String field spec.
Returns#
- isString
bool The field refers to a
sqlalchemy.Stringand not any other type. This can returnFalseeven if the object was created with a string type if it has been decided that it should be implemented as asqlalchemy.Texttype.
- isString