PSCue now includes functions to query the SQLite database directly, allowing you to inspect what's actually persisted on disk vs. what's in memory.
Gets statistics directly from the SQLite database file.
Basic Usage:
Get-PSCueDatabaseStatsOutput:
TotalCommands : 15
TotalArguments : 142
TotalHistoryEntries : 89
TotalCoOccurrences : 234
TotalFlagCombinations : 23
DatabaseSizeKB : 156.50
DatabasePath : C:\Users\...\AppData\Local\PSCue\learned-data.db
TopCommands : {git, docker, kubectl, ...}
Detailed Mode:
Get-PSCueDatabaseStats -DetailedShows per-command statistics including top arguments with usage counts.
JSON Export:
Get-PSCueDatabaseStats -AsJson | Out-File db-stats.jsonGets command history entries directly from the database.
Basic Usage:
Get-PSCueDatabaseHistoryShows last 20 history entries (default).
Show more entries:
Get-PSCueDatabaseHistory -Last 50Filter by command:
Get-PSCueDatabaseHistory -Command "git"Output:
Id Command CommandLine Timestamp Success
-- ------- ----------- --------- -------
89 git git status 2025-10-30 9:45:12 True
88 docker docker ps 2025-10-30 9:43:08 True
87 git git log --oneline 2025-10-30 9:42:01 True
PSCue uses SQLite with the following tables:
command(TEXT PRIMARY KEY) - Command nametotal_usage_count(INTEGER) - How many times usedfirst_seen(TEXT) - First observation timestamplast_used(TEXT) - Last usage timestamp
command(TEXT) - Parent commandargument(TEXT) - Argument textusage_count(INTEGER) - Usage frequencyfirst_seen(TEXT) - First observationlast_used(TEXT) - Last usageis_flag(BOOLEAN) - Whether it's a flag (starts with -)
id(INTEGER PRIMARY KEY) - Auto-increment IDcommand(TEXT) - Command namecommand_line(TEXT) - Full command linearguments(TEXT) - JSON array of argumentstimestamp(TEXT) - Execution timesuccess(BOOLEAN) - Whether command succeededworking_directory(TEXT) - Working directory when executed
Tracks which arguments are used together.
Tracks common flag combinations (e.g., -la for ls -la).
Get-PSCueLearning- Shows what's currently loaded in ArgumentGraph (memory)- Fast access, current session state
Get-PSCueDatabaseStats- Shows what's persisted on diskGet-PSCueDatabaseHistory- Shows historical command executions- Survives PowerShell restarts, cross-session data
- Auto-save interval - Data is saved every 5 minutes
- Module just loaded - Data may not be synced yet
- Manual save needed - Run
Save-PSCueLearningto sync immediately
Check sync status:
$inMemory = (Get-PSCueLearning).Count
$inDb = (Get-PSCueDatabaseStats).TotalCommands
Write-Host "In memory: $inMemory | In database: $inDb"
if ($inMemory -ne $inDb) {
Save-PSCueLearning # Force sync
}Windows:
C:\Users\<username>\AppData\Local\PSCue\learned-data.db
Linux/macOS:
~/.local/share/PSCue/learned-data.db
Get path programmatically:
[PSCue.Module.PSCueModule]::Persistence.DatabasePath- Uses SQLite WAL (Write-Ahead Logging) mode
- Multiple PowerShell sessions can read/write safely
- 5-second busy timeout for concurrent access
- Additive merging: frequencies summed, timestamps use max
# Check if data is actually being persisted
Get-PSCueDatabaseStats
# See what commands have been tracked
Get-PSCueDatabaseHistory
# Compare in-memory vs database
Get-PSCueLearning
Get-PSCueDatabaseStats# Export all historical commands
Get-PSCueDatabaseHistory -Last 1000 | Export-Csv command-history.csv
# Export detailed statistics
Get-PSCueDatabaseStats -Detailed -AsJson | Out-File db-stats.json# See which git commands you use most
Get-PSCueDatabaseHistory -Command "git" |
Group-Object CommandLine |
Sort-Object Count -Descending |
Select-Object Count, Name -First 10$stats = Get-PSCueDatabaseStats
Write-Host "Database Size: $($stats.DatabaseSizeKB) KB"
Write-Host "Total Commands: $($stats.TotalCommands)"
Write-Host "Total Arguments: $($stats.TotalArguments)"
Write-Host "History Entries: $($stats.TotalHistoryEntries)"
if ($stats.TotalCommands -eq 0) {
Write-Host "No learning data yet - run some commands!"
}Get-PSCueLearning- In-memory learning dataSave-PSCueLearning- Force save to databaseClear-PSCueLearning- Clear database and memoryExport-PSCueLearning- Export to JSONImport-PSCueLearning- Import from JSON
These functions use Microsoft.Data.Sqlite directly to query the database:
- Read-only connection for safety
- 5-second busy timeout for concurrency
- Proper connection disposal (no locks left behind)
- Very fast - direct SQL queries
- No impact on in-memory learning system
- Can run anytime without disrupting predictions
module/Functions.ps1- Consolidated module functions; database query functions live in theDatabase Managementregionmodule/PSCue.psm1- Dot-sources Functions.ps1module/PSCue.psd1- ExportsGet-PSCueDatabaseStatsandGet-PSCueDatabaseHistory