Welcome!
prefect-sqlalchemy helps you connect to a database in your Prefect flows.
Getting started
Install prefect-sqlalchemy
The following command will install a version of prefect-sqlalchemy compatible with your installed version of prefect.
If you don’t already have prefect installed, it will install the newest version of prefect as well.
prefect and prefect-sqlalchemy:
Register newly installed block types
Register the block types in theprefect-sqlalchemy module to make them available for use.
Examples
Save credentials to a block
To use theload method on Blocks, you must have a block saved through code or saved through the UI.
driver and database arguments:
Work with databases in a flow
To set up a table, use theexecute and execute_many methods.
Use the fetch_many method to retrieve data in a stream until there’s no more data.
Use the SqlAlchemyConnector as a context manager, to ensure that the SQLAlchemy engine and any connected resources are closed properly after you’re done with them.
Async support
SqlAlchemyConnector  supports async workflows. Just be sure to save, load, and use an async driver, as in the example below.- Sync
- Async
Resources
Refer to theprefect-sqlalchemy SDK documentation to explore all the capabilities of the prefect-sqlalchemy library.
For assistance using SQLAlchemy, consult the SQLAlchemy documentation.