Skip to main content

demo_db_path

Function demo_db_path 

Source
pub fn demo_db_path() -> PathBuf
Expand description

Resolve the writable filesystem path for the demo SQLite database.

On AWS Lambda the deployment root (/var/task) is read-only, so a SQLite database that must be created/seeded at startup has to live under the writable /tmp. Locally a relative demo.db in the working directory is fine. Lambda is detected by the presence of the LAMBDA_TASK_ROOT environment variable, which the Lambda runtime always sets.

This pairs with pmcp::assets::load_string("config.toml") / pmcp::assets::load_string("schema.sql") for read-only assets — config and schema are bundled (and resolved) via the pmcp asset loader, while the mutable database goes wherever this resolver points. Both halves are decided once here so the example, the scaffold emitter, and the deploy path share one shape (Phase 86 Review H1).

§Examples

use pmcp_server_toolkit::demo_db_path;

// Locally (no LAMBDA_TASK_ROOT) the demo DB is a relative file.
std::env::remove_var("LAMBDA_TASK_ROOT");
assert_eq!(demo_db_path(), std::path::PathBuf::from("demo.db"));