Database¶
It can be imported from fluid.db
:
fluid.db.Database
dataclass
¶
Database(
dsn,
echo=DBECHO,
pool_size=DBPOOL_MAX_SIZE,
max_overflow=DBPOOL_MAX_OVERFLOW,
metadata=MetaData(),
migration_path="",
app_name=APP_NAME,
_engine=None,
)
A container for tables in a database and a manager of asynchronous connections to a postgresql database
dsn
instance-attribute
¶
data source name, aka connection string
Example: "postgresql+asyncpg://user:password@localhost/dbname"
engine
property
¶
The :class:sqlalchemy.ext.asyncio.AsyncEngine
creating connection
and transactions
from_env
classmethod
¶
Create a new database container from environment variables as defaults
Source code in fluid/db/container.py
cli
¶
connection
async
¶
Context manager for obtaining an asynchronous connection
ensure_connection
async
¶
Context manager for obtaining an asynchronous connection
Source code in fluid/db/container.py
transaction
async
¶
Context manager for initializing an asynchronous database transaction
ensure_transaction
async
¶
Context manager for ensuring we a connection has initialized a database transaction