Coverage for python/lsst/daf/butler/core/schema.py : 90%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# This file is part of daf_butler. # # Developed for the LSST Data Management System. # This product includes software developed by the LSST Project # (http://www.lsst.org). # See the COPYRIGHT file at the top-level directory of this distribution # for details of code ownership. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>.
Float, ForeignKeyConstraint, Table, MetaData
"""The SQL schema for a Butler Registry.
Parameters ---------- dataUnits : `DataUnitsRegistry` Registry of all possible data units. config : `SchemaConfig` or `str`, optional Load configuration. Defaults will be read if ``config`` is not a `SchemaConfig`.
Attributes ---------- metadata : `sqlalchemy.MetaData` The sqlalchemy schema description. """
self._views.items())}
"""Builds a Schema step-by-step.
Attributes ---------- metadata : `sqlalchemy.MetaData` The sqlalchemy schema description. tables : `dict` All created tables. views : `dict` All created views. """ "bool": Boolean, "blob": LargeBinary, "datetime": DateTime}
"""Add a table to the schema metadata.
Parameters ---------- tableName : `str` Key of the table. tableDescription : `dict` Table description.
Requires: - columns, a list of column descriptions - foreignKeys, a list of foreign-key constraint descriptions
Raises ------ ValueError If a table with the given name already exists. """ raise ValueError("Table with name {} already exists".format(tableName)) # Create a Table object (attaches itself to metadata) # This table can be materialized as a view else: raise ValueError("No columns in table: {}".format(tableName))
"""Add a column to a table.
Parameters ---------- table : `sqlalchemy.Table`, `sqlalchemy.expression.TableClause` or `str` The table. columnDescription : `dict` Description of the column to be created. Should always contain: - name, descriptive name - type, valid column type May contain: - nullable, entry can be null - primary_key, mark this column as primary key - foreign_key, link to other table - doc, docstring """ table = self.metadata.tables[table]
"""Add a ForeignKeyConstraint to a table.
Parameters ---------- table : `sqlalchemy.Table` or `str` The table. constraintDescription : `dict` Description of the ForeignKeyConstraint to be created. Should always contain: - src, list of source column names - tgt, list of target column names """ table = self.metadata.tables[table]
"""Make a Column entry for addition to a Table.
Parameters ---------- columnDescription : `dict` Description of the column to be created. Should always contain: - name, descriptive name - type, valid column type May contain: - nullable, entry can be null - primary_key, mark this column as primary key - doc, docstring
Returns ------- c : `sqlalchemy.Column` The created `Column` entry.
Raises ------ ValueError If the column description contains unsupported arguments """ # required # additional optional arguments can be passed through directly raise ValueError("Unhandled extra kwargs: {} for column: {}".format(description, columnName))
"""Make a ForeignKeyConstraint for addition to a Table.
Parameters ---------- constraintDescription : `dict` Description of the ForeignKeyConstraint to be created. Should always contain: - src, list of source column names - tgt, list of target column names """ |