Relational
matchlab.sources.relational
¶
Reading a source from a relational database.
Classes:
-
ClientType–The client libraries a relational location can be driven by.
-
RelationalDB–A relational database, and the query that extracts a source's rows from it.
Attributes:
-
DBClient(TypeAlias) –What a
RelationalDBreads through: a SQLAlchemy engine or an ADBC connection.
DBClient
module-attribute
¶
DBClient: TypeAlias = Engine | Connection
What a RelationalDB reads through: a SQLAlchemy engine or an ADBC connection.
ClientType
¶
Bases: StrEnum
flowchart TD
matchlab.sources.relational.ClientType[ClientType]
click matchlab.sources.relational.ClientType href "" "matchlab.sources.relational.ClientType"
The client libraries a relational location can be driven by.
Attributes:
-
SQLALCHEMY– -
ADBC–
RelationalDB
¶
Bases: Location
flowchart TD
matchlab.sources.relational.RelationalDB[RelationalDB]
matchlab.sources.base.Location[Location]
matchlab.sources.base.Location --> matchlab.sources.relational.RelationalDB
click matchlab.sources.relational.RelationalDB href "" "matchlab.sources.relational.RelationalDB"
click matchlab.sources.base.Location href "" "matchlab.sources.base.Location"
A relational database, and the query that extracts a source's rows from it.
Methods:
-
read–Get this location's rows, in batches.
Attributes:
-
sql(SQLQuery) –SQL producing the rows to read, in whatever dialect the client speaks.
-
client(FromResources[DBClient]) –The SQLAlchemy engine or ADBC connection to read through.
-
client_type(ClientType) –Which client type this location was built with.
-
model_config–
sql
instance-attribute
¶
SQL producing the rows to read, in whatever dialect the client speaks.
client
instance-attribute
¶
client: FromResources[DBClient]
The SQLAlchemy engine or ADBC connection to read through.
client_type
property
¶
client_type: ClientType
Which client type this location was built with.
One isinstance decides it, because the field's type has already rejected
anything that is neither an Engine nor an ADBC connection.
model_config
class-attribute
instance-attribute
¶
read
¶
read(batch_size: int | None = None, rename: dict[str, str] | Callable | None = None, return_type: DataFrameType = POLARS, schema_overrides: dict[str, DataType] | None = None) -> Generator[DataFrameClass, None, None]
Get this location's rows, in batches.
Parameters:
-
(batch_size¶int | None, default:None) –The size used for internal batching.
-
(rename¶dict[str, str] | Callable | None, default:None) –Renaming to apply to the rows that come back.
- If a dictionary is provided, it will be used to rename the columns.
- If a callable is provided, it will take the old name as input and return the new name.
-
(return_type¶DataFrameType, default:POLARS) –The type of data to return. Defaults to "polars".
-
(schema_overrides¶dict[str, DataType] | None, default:None) –Types to force on the columns that come back, rather than letting the location infer them.