FieldSpec

class lsst.daf.butler.FieldSpec(name: str, dtype: type, length: Optional[int] = None, nbytes: Optional[int] = None, primaryKey: bool = False, autoincrement: bool = False, nullable: bool = True, doc: Optional[str] = None)

Bases: object

A struct-like class used to define a column in a logical Registry table.

Attributes Summary

autoincrement

Whether the database should insert automatically incremented values when no value is provided in an INSERT.

doc

Documentation for this field.

length

Length of the type in the database, for variable-length types.

nbytes

Natural length used for hash and encoded-region columns, to be converted into the post-encoding length.

nullable

Whether this field is allowed to be NULL.

primaryKey

Whether this field is (part of) its table’s primary key.

Methods Summary

fromConfig(config, *args, **kwds)

getSizedColumnType()

Return a sized version of the column type, utilizing either (or neither) of self.length and self.nbytes.

toSqlAlchemy(tableName, schema)

Construct a SQLAlchemy Column object from this specification.

Attributes Documentation

autoincrement = False

Whether the database should insert automatically incremented values when no value is provided in an INSERT.

doc = None

Documentation for this field.

length = None

Length of the type in the database, for variable-length types.

nbytes = None

Natural length used for hash and encoded-region columns, to be converted into the post-encoding length.

nullable = True

Whether this field is allowed to be NULL.

primaryKey = False

Whether this field is (part of) its table’s primary key.

Methods Documentation

classmethod fromConfig(config, *args, **kwds)
getSizedColumnType() → sqlalchemy.sql.type_api.TypeEngine

Return a sized version of the column type, utilizing either (or neither) of self.length and self.nbytes.

Returns
dtypesqlalchemy.types.TypeEngine

A SQLAlchemy column type object.

toSqlAlchemy(tableName: str, schema: lsst.daf.butler.core.schema.Schema) → sqlalchemy.sql.schema.Column

Construct a SQLAlchemy Column object from this specification.

Parameters
tableNamestr

Name of the logical table to which this column belongs.

schemaSchema

Object represening the full schema. May be modified in-place.

Returns
columnsqlalchemy.Column

SQLAlchemy column object.