get_reference_sa_composite

get_reference_sa_composite(prefix_column: Column[str], identifier_column: Column[str], **kwargs: Any) Composite[Reference][source]

Get a composite for a reference.

Parameters:
  • prefix_column – The column for the reference’s prefix

  • identifier_column – The column for the reference’s identifier

  • kwargs – keyword arguments passed to sqlalchemy.orm.composite()

Returns:

A Composite object for a reference

from curies import Reference
from curies.database import get_reference_sa_composite
from sqlalchemy import Column
from sqlalchemy.orm import DeclarativeBase


class Base(DeclarativeBase):
    pass


class Edge(Base):
    __tablename__ = "edge"

    id = Column(Integer, primary_key=True)

    subject_prefix = Column(String, nullable=False)
    subject_identifier = Column(String, nullable=False)
    predicate_prefix = Column(String, nullable=False)
    predicate_identifier = Column(String, nullable=False)
    object_prefix = Column(String, nullable=False)
    object_identifier = Column(String, nullable=False)

    subject = get_reference_sa_composite(subject_prefix, subject_identifier)
    predicate = get_reference_sa_composite(predicate_prefix, predicate_identifier)
    object = get_reference_sa_composite(object_prefix, object_identifier)