PGlite Database Management in VS Code
Overview
Section titled “Overview”PGlite is the full PostgreSQL engine compiled to WebAssembly, packaged so it runs anywhere Node or a browser runs. Inside DBCode it behaves like SQLite or DuckDB — embedded, single-process, no server to start — but with the SQL surface and feature set of Postgres 17.
Highlights:
- Embedded Postgres: Real
postgresbinary running in WASM. Same dialect, same catalogs, sameEXPLAIN. - Two storage modes: In-memory (data discarded when the connection closes) or a persistent directory on disk.
- No external dependencies: PGlite ships inside DBCode; nothing to install.
- Full Postgres feature set: tables, partitions, views, materialized views, procedures, functions, sequences, triggers, row-level security, enum/composite types, generated columns, JSONB, arrays.
PGlite is a great fit for prototypes, test fixtures, throw-away analysis, or shipping a Postgres-flavored database alongside a desktop app.
Connecting
Section titled “Connecting”To connect to a PGlite database in DBCode:
- Open the DBCode Extension: Launch Visual Studio Code and open the DBCode extension.
- Add a New Connection: Click the “Add Connection” icon and choose PGlite.
- Pick a storage type:
- In Memory — fastest start; data is lost when the connection closes. Good for ad-hoc work and tests.
- Directory — persists data to a folder on disk. Pick an empty directory for a new database, or an existing PGlite directory to reopen one.
- Connect: Click save to establish your connection.
- Query away: PGlite supports the same SQL you’d run against any Postgres 17 server.
For detailed instructions on setting up connections, refer to the Connect article.
PGlite features in DBCode
Section titled “PGlite features in DBCode”DBCode’s PGlite driver supports:
- Full schema browser: schemas, tables, partitions, views, materialized views, procedures, functions, sequences, types, triggers, indexes, and policies — discovered via the same v3 progressive introspection used by the standard Postgres driver.
- DDL scripting:
CREATEstatements for every supported object, generated bypg_dumpfor tables andpg_get_*def()for routines, views, triggers, and indexes. - Execution plans:
EXPLAINandEXPLAIN (ANALYZE, BUFFERS)rendered in DBCode’s plan visualizer. - Row counts on demand: PGlite has no autovacuum, so
pg_class.reltuplesstays at -1 until you ask for it. Toggle Update Statistics on the connection (Advanced → Introspection) to runANALYZEautomatically when you refresh a schema.
Storage tips
Section titled “Storage tips”- In-memory mode is exactly what it sounds like - close the connection and the data is gone. Use it for scratch databases.
- Directory mode writes a full Postgres data directory at the path you choose. Back it up like you would any Postgres
PGDATAfolder. - Don’t share a directory between concurrent connections. PGlite is single-process; opening the same directory from two clients at once will conflict.
Limitations
Section titled “Limitations”A few things real Postgres has that embedded PGlite does not:
- No foreign data wrappers (FDW) — there’s no extension loader, so external tables and foreign servers aren’t available.
- No logical replication / publications / subscriptions.
- No autovacuum — see the Update Statistics toggle above for live row counts.
- Single connection — PGlite serializes all queries through one WASM instance.
For more information about PGlite, check out pglite.dev.