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:
object
A data class for defining a column in a logical
Registry
table.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.
Length of the type in the database, for variable-length types.
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
FieldSpec
for 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_default
argument 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.
- 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
primaryKey
isTrue
, during construction this value will be forced toFalse
.
Methods Documentation
- classmethod for_region(name: str = 'region', nullable: bool = True, nbytes: int = 2048) FieldSpec ¶
Create a
FieldSpec
for a spatial region column.- Parameters:
- Returns:
- spec
FieldSpec
Specification structure for a region column.
- spec
- 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.length
andself.nbytes
.- Returns:
- dtype
sqlalchemy.types.TypeEngine
A SQLAlchemy column type object.
- dtype