Skip to content

Instantly share code, notes, and snippets.

@milnak
Created February 17, 2025 23:39
Show Gist options
  • Save milnak/02bd5a7356a29ed37dabab9137215908 to your computer and use it in GitHub Desktop.
Save milnak/02bd5a7356a29ed37dabab9137215908 to your computer and use it in GitHub Desktop.
Dump Sqlite Table using PowerShell
$SqliteAssembly = Resolve-Path -LiteralPath '~\scoop\apps\scoop\current\supporting\sqlite\System.Data.SQLite.dll'
$DbPath = Resolve-Path -LiteralPath '~\AppData\Roaming\Code\User\globalStorage\state.vscdb'
if (!('System.Data.SQLite.SQLiteConnection' -as [Type])) {
Add-Type -Path $SqliteAssembly
}
$connection = New-Object -TypeName 'Data.SQLite.SQLiteConnection'
$connection.ConnectionString = "Data Source=$DbPath"
$connection.Open()
$command = $connection.CreateCommand()
$command.CommandText = @"
SELECT json_extract(value, '$.entries')
AS entries
FROM ItemTable
WHERE key = 'history.recentlyOpenedPathsList'
"@
$command.CommandType = [Data.CommandType]::Text
$reader = $command.ExecuteReader()
# Colnames: $reader.GetValues()
while ($reader.HasRows) {
if ($reader.Read()) {
$reader['entries']
}
}
$reader.Close()
$command.Dispose()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment