Configuration Guide¶
Overview¶
The HomeBudget wrapper uses a JSON configuration file to manage database paths, sync settings, and forex preferences. This eliminates the need to specify these settings for every command.
Configuration File Location¶
Default path:
Alternative locations checked (in order):
- Path specified by
HB_CONFIGenvironment variable - Default path shown above
Configuration File Format¶
Complete configuration example:
{
"db_path": "C:\\Users\\taylo\\OneDrive\\Documents\\HomeBudgetData\\Data\\homebudget.db",
"sync_enabled": true,
"base_currency": "SGD",
"forex": {
"cache_ttl_hours": 1
}
}
Configuration Fields¶
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
db_path |
string | Yes | N/A | Absolute path to HomeBudget database file |
sync_enabled |
boolean | No | true |
Enable/disable SyncUpdate creation |
base_currency |
string | No | From DB | Base currency code (e.g., "SGD", "USD") |
forex.cache_ttl_hours |
number | No | 1 |
Forex rate cache validity in hours |
Default database path:
Setup Instructions¶
First-Time Setup¶
Create configuration directory and file:
# Windows PowerShell
$configDir = "$env:USERPROFILE\OneDrive\Documents\HomeBudgetData"
New-Item -ItemType Directory -Force -Path $configDir
Copy-Item config\hb-config.json.sample "$configDir\hb-config.json"
Edit the configuration file:
Open %USERPROFILE%\OneDrive\Documents\HomeBudgetData\hb-config.json and update:
- Set
db_pathto your operational HomeBudget database location - Verify
base_currencymatches your database - Adjust
sync_enabledif needed (default:true)
UAT (User Acceptance Testing) Setup¶
For UAT tests with live database and mobile sync:
- Set
db_pathto operational database - Set
sync_enabledtotrue - Ensure HomeBudget apps (Windows and mobile) use the same database
SIT (System Integration Testing) Setup¶
For SIT tests with headless fixtures:
- No configuration file needed
- Tests use fixtures from
tests/fixtures/ - Configuration is ignored during SIT
Using Configuration¶
With methods¶
Configuration is loaded automatically when creating a client:
from homebudget import HomeBudgetClient
# Uses config file automatically
with HomeBudgetClient() as client:
expenses = client.list_expenses()
Override with explicit path:
# Ignore config file, use explicit path
with HomeBudgetClient(db_path="C:/path/to/homebudget.db") as client:
expenses = client.list_expenses()
With CLI¶
Configuration is loaded automatically for all commands:
Override with --db flag:
Configuration Behavior¶
Loading Priority¶
The wrapper loads configuration in this order (first found wins):
- Explicit parameter: Methods
db_pathparameter or CLI--dbflag - Environment variable:
HB_CONFIGpointing to config file - Default location:
%USERPROFILE%\OneDrive\Documents\HomeBudgetData\hb-config.json
Sync Control¶
Sync behavior is determined by configuration:
- Config file:
sync_enabledsetting (default:true) - Default:
trueif not specified
Sync is always enabled via CLI and cannot be disabled to ensure consistency between local and remote devices.
Missing Configuration¶
If no configuration file exists:
- Methods: Must provide
db_pathparameter, or will raise error - CLI: Must provide
--dbflag, or will raise error
Sample Configuration File¶
A complete sample is provided at config/hb-config.json.sample:
{
"db_path": "C:\\Users\\USERNAME\\OneDrive\\Documents\\HomeBudgetData\\Data\\homebudget.db",
"sync_enabled": true,
"base_currency": "SGD",
"forex": {
"cache_ttl_hours": 1
}
}
To use:
- Copy to the default location
- Replace
USERNAMEwith your actual username - Adjust paths and currency as needed
Troubleshooting¶
"Config file not found" Error¶
Problem: CLI or methods cannot locate configuration file.
Solution:
- Check file exists at default location
- Verify path in error message
- Use
--dbflag ordb_pathparameter as workaround
"Database path not in config" Error¶
Problem: Config file exists but db_path field is missing.
Solution:
- Open config file
- Add
"db_path": "C:\\path\\to\\homebudget.db" - Ensure path uses double backslashes on Windows
Sync Not Working¶
Problem: Changes don't appear in mobile app.
Solution:
- Verify
sync_enabled: truein config - Confirm DeviceInfo exists in database
- Verify mobile app uses same database
Related Documentation¶
- User Guide - Getting started and usage examples
- Developer Guide - Development workflow and testing
- CLI Guide - Command-line usage examples
- Sync Update Mechanism - How sync works