Skip to content

SimpleSqlAlchemyFetcher#

dbally.similarity.SimpleSqlAlchemyFetcher #

SimpleSqlAlchemyFetcher(sqlalchemy_engine: Engine, column: ColumnClause, table: Table)

Bases: SqlAlchemyFetcher

Fetches the data from a single column in the database.

Source code in src/dbally/similarity/sqlalchemy_base.py
def __init__(
    self, sqlalchemy_engine: sqlalchemy.engine.Engine, column: ColumnClause, table: sqlalchemy.Table
) -> None:
    super().__init__(sqlalchemy_engine)
    self.column = column
    self.table = table

sqlalchemy_engine instance-attribute #

sqlalchemy_engine = sqlalchemy_engine

column instance-attribute #

column = column

table instance-attribute #

table = table

fetch async #

fetch() -> List[str]

Fetches the data from the source and returns it as a list of strings.

RETURNS DESCRIPTION
List[str]

The fetched data.

Source code in src/dbally/similarity/sqlalchemy_base.py
async def fetch(self) -> List[str]:
    """
    Fetches the data from the source and returns it as a list of strings.

    Returns:
        The fetched data.
    """
    with self.sqlalchemy_engine.connect() as conn:
        result = conn.execute(self.get_query())
        return [row[0] for row in result]

get_query #

get_query() -> Select

Returns query that will be used to fetch the data from the database.

RETURNS DESCRIPTION
Select

The query to fetch the data.

Source code in src/dbally/similarity/sqlalchemy_base.py
def get_query(self) -> sqlalchemy.Select:
    """
    Returns query that will be used to fetch the data from the database.

    Returns:
        The query to fetch the data.
    """
    return sqlalchemy.select(self.column).select_from(self.table).distinct()