mud_server.db.connection
SQLite connection primitives for the MUD server DB layer.
This module owns connection creation and low-level SQLite runtime pragmas so repository code can stay focused on queries and transaction intent.
Functions
Resolve the absolute SQLite database path from runtime configuration. |
|
|
Apply connection-level SQLite pragmas required by the application. |
Create and configure a new SQLite connection. |
|
|
Yield a configured connection with guaranteed cleanup semantics. |
Module Contents
- mud_server.db.connection.get_db_path()[source]
Resolve the absolute SQLite database path from runtime configuration.
- mud_server.db.connection.configure_connection(connection)[source]
Apply connection-level SQLite pragmas required by the application.
Notes
foreign_keys=ONis required because SQLite does not enforce foreign-key constraints by default.busy_timeoutreduces transient lock failures during short-lived concurrent writes in tests and local multi-process development.
- mud_server.db.connection.connection_scope(*, write=False)[source]
Yield a configured connection with guaranteed cleanup semantics.
- Parameters:
write (bool) – When True, commit on success and rollback on exceptions.
- Yields:
Configured SQLite connection ready for cursor operations.
- Behavior:
Always closes the connection in
finally.For write scopes, commits at the end of a successful block.
For write scopes, attempts rollback before re-raising failures.