pyaccesskit.schema.relationships¶
pyaccesskit.schema.relationships ¶
Relationship specifications.
ColumnRef
module-attribute
¶
ColumnRef = str | tuple[str, str | Sequence[str]]
A relationship end: "Table.Column", ("Table", "Column") or ("Table", ["Col1", "Col2"]).
RelationshipSpec ¶
Bases: SpecModel
A relationship between a primary ("one") table and a foreign ("many") table.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str | None
|
Relationship name. Defaults to Access's convention: primary table name + foreign table name. |
primary_table |
str
|
The table on the "one" side (its columns need a primary key or unique index). |
primary_columns |
Items[str]
|
Referenced columns of the primary table. |
foreign_table |
str
|
The table on the "many" side. |
foreign_columns |
Items[str]
|
Referencing columns of the foreign table (same count and compatible types). |
enforce_integrity |
bool
|
Enforce referential integrity (the default; creates a hidden index). |
cascade_update |
bool
|
Cascade updates of the primary key to related rows. |
cascade_delete |
bool
|
Cascade deletes to related rows. |
one_to_one |
bool
|
Declare a one-to-one relationship. |
join |
JoinType
|
Default join type used by the query designer. |
effective_name
property
¶
effective_name: str
name or Access's default name (primary table + foreign table).
between
classmethod
¶
between(
primary: ColumnRef, foreign: ColumnRef, **options: Any
) -> RelationshipSpec
Build a relationship from "Table.Column" references.
Example::
RelationshipSpec.between("Customers.CustomerID", "Orders.CustomerID", cascade_delete=True)