From 0542f4b62ec8f38410da8dc386418662cb8d8f72 Mon Sep 17 00:00:00 2001 From: gusto Date: Thu, 21 May 2026 17:48:33 +0300 Subject: [PATCH] Set sqlite db path via env --- README.md | 2 ++ src/core/app.py | 2 ++ src/node/lifespan.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 93c29cb..76b1b91 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,8 @@ NBE_NODE_API_PROTOCOL=http # Only used if NODE_API=http NBE_HOST=0.0.0.0 # Block Explorer's listening host NBE_PORT=8000 # Block Explorer's listening port + +NBE_DATABASE_URL=sqlite:///sqlite.db # Database connection URL ``` If running the Block Explorer with Docker, these can be overridden. diff --git a/src/core/app.py b/src/core/app.py index 0254990..bbe249b 100644 --- a/src/core/app.py +++ b/src/core/app.py @@ -31,6 +31,8 @@ class NBESettings(BaseSettings): node_api_protocol: str = Field(alias="NBE_NODE_API_PROTOCOL", default="http") node_api_auth: Optional[Authentication] = Field(alias="NBE_NODE_API_AUTH", default=None) + database_url: str = Field(alias="NBE_DATABASE_URL", default=f"sqlite:///{DIR_REPO}/sqlite.db") + @field_validator("node_api_auth", mode="before") @classmethod def parse_auth(cls, value: str) -> Optional[Authentication]: diff --git a/src/node/lifespan.py b/src/node/lifespan.py index deb37cc..1abcccd 100644 --- a/src/node/lifespan.py +++ b/src/node/lifespan.py @@ -95,7 +95,7 @@ async def node_lifespan(app: "NBE") -> AsyncGenerator[None]: app.state.node_manager = build_node_manager(app.settings) app.state.node_api = build_node_api(app.settings) - db_client = SqliteClient() + db_client = SqliteClient(sqlite_db_path=app.settings.database_url) app.state.db_client = db_client app.state.block_repository = BlockRepository(db_client) app.state.transaction_repository = TransactionRepository(db_client)