Blocks Catalog
Below is a list of Blocks available for registration in
prefect-sqlalchemy
.
To register blocks in this module to view and edit them on Prefect Cloud, first install the required packages, then
prefect block register -m prefect_sqlalchemy
load
method on Blocks, you must already have a block document saved through code or saved through the UI.
Credentials Module
Block used to manage authentication with a database.
To load the DatabaseCredentials:
from prefect import flow
from prefect_sqlalchemy.credentials import DatabaseCredentials
@flow
def my_flow():
my_block = DatabaseCredentials.load("MY_BLOCK_NAME")
my_flow()
Database Module
Block used to manage authentication with a database.
Upon instantiating, an engine is created and maintained for the life of the object until the close method is called.
It is recommended to use this block as a context manager, which will automatically close the engine and its connections when the context is exited.
It is also recommended that this block is loaded and consumed within a single task or flow because if the block is passed across separate tasks and flows, the state of the block's connection and cursor could be lost.
To load the SqlAlchemyConnector:
from prefect import flow
from prefect_sqlalchemy.database import SqlAlchemyConnector
@flow
def my_flow():
my_block = SqlAlchemyConnector.load("MY_BLOCK_NAME")
my_flow()