co3.components package

Dev note:

Any reason to have ComposeableComponents and Relations as separate types? The thought is that there may be some possible Component types we want to be able to Compose that wouldn’t logically be Relations. But the gap here might be quite small

class co3.components.ComposableComponent(name, obj)[source]

Bases: Component, Generic

Components that can be composed with others of the same type.

abstract compose(component, on, outer=False)[source]

Abstract composition.

Return type:

Self

class co3.components.Dictionary(name, obj)[source]

Bases: Relation[dict]

get_attributes()[source]
class co3.components.Document(name, obj)[source]

Bases: Component, Generic

class co3.components.FTSTable(name, obj)[source]

Bases: Relation[SQLTableLike]

class co3.components.Node(name, obj)[source]

Bases: Component, Generic

class co3.components.Relation(name, obj)[source]

Bases: ComposableComponent, Generic

Relation base for tabular components to be used in relation DB settings. Attempts to adhere to the set-theoretic base outlined in the relational model [1]. Some terminology:

Relation: table-like container | -> Heading: set of attributes | | -> Attribute: column name | -> Body: set of tuples with domain matching the heading | | -> Tuple: collection of values

[1]: https://en.wikipedia.org/wiki/Relational_model#Set-theoretic_formulation

Note: development tasks

As it stands, the Relation skeleton is incredibly lax compared to the properties and operations that should be formally available, according its pure relational algebra analog.

Relations are also generic up to a type T, which ultimately serves as the base object for Relation instances. We aren’t attempting to implement some generally useful table-like class here; instead we’re just exposing a lightweight interface that’s needed for a few CO3 contexts, and commonly off-loading most of the heavy-lifting to true relation objects like SQLAlchemy tables.

compose(_with, on, outer=False)[source]

Abstract composition.

class co3.components.SQLTable(name, obj)[source]

Bases: Relation[SQLTableLike]

compose(_with, on, outer=False)[source]

Abstract composition.

classmethod from_table(table)[source]

Note that the sa.Table type is intentional here; not all matching types for SQLTableLike have a defined name property

get_attributes()[source]
Return type:

tuple

get_column_defaults(include_all=True)[source]

Provide column:default pairs for a provided SQLAlchemy table.

Parameters:

include_all – whether to include all columns, even those without explicit defaults

prepare_insert_data(insert_data)[source]

Modifies insert dictionary with full table column defaults

Return type:

dict