Async Database¶
The fluid.db module provides a simple asynchronous interface to interact with postgres databases. It is built on top of the sqlalchemy and asyncpg libraries.
Installation¶
To use the database module, you need to install the db extra, and optionally the cli extra if you want to use the command line interface for managing database migrations:
Database¶
Create a database container with the Database class:
from fluid.db import Database
db = Database("postgresql+asyncpg://postgres:postgres@localhost:5432/fluid")
Note the use of the postgresql+asyncpg driver in the connection string. This is required to use the asyncpg driver.
Register a Table¶
To interact with a table, you need to register it with the database container: