nexusLIMS.db.engine#
Database engine and session management for NexusLIMS.
Module Contents#
Functions#
Create a short-lived file-backed SQLite engine without connection pooling. |
|
Create an in-memory SQLite engine backed by a single shared connection. |
|
Get the database engine, creating it lazily on first access. |
API#
- nexusLIMS.db.engine.create_transient_sqlite_engine(db_path: Path | str, *, echo: bool = False) Engine[source]#
Create a short-lived file-backed SQLite engine without connection pooling.
This is the preferred helper for one-shot CLI utilities, fixtures, and tests that create a file-backed SQLite engine for a narrow scope and dispose it explicitly when finished.
- nexusLIMS.db.engine.create_in_memory_engine(*, echo: bool = False) Engine[source]#
Create an in-memory SQLite engine backed by a single shared connection.
Tests that need an in-memory database should use this helper so the same SQLite database remains available across sessions and threads.
- nexusLIMS.db.engine.get_engine() Engine[source]#
Get the database engine, creating it lazily on first access.
- Returns:
The SQLAlchemy/SQLModel engine for the NexusLIMS database.
- Return type:
Examples:
>>> from nexusLIMS.db.engine import get_engine >>> engine = get_engine() >>> # Use engine for advanced operations