Skip to content

PGlite Database Management in VS Code

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 postgres binary running in WASM. Same dialect, same catalogs, same EXPLAIN.
  • 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.

To connect to a PGlite database in DBCode:

  1. Open the DBCode Extension: Launch Visual Studio Code and open the DBCode extension.
  2. Add a New Connection: Click the “Add Connection” icon and choose PGlite.
  3. 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.
  4. Connect: Click save to establish your connection.
  5. 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.

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: CREATE statements for every supported object, generated by pg_dump for tables and pg_get_*def() for routines, views, triggers, and indexes.
  • Execution plans: EXPLAIN and EXPLAIN (ANALYZE, BUFFERS) rendered in DBCode’s plan visualizer.
  • Row counts on demand: PGlite has no autovacuum, so pg_class.reltuples stays at -1 until you ask for it. Toggle Update Statistics on the connection (Advanced → Introspection) to run ANALYZE automatically when you refresh a schema.
  • 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 PGDATA folder.
  • Don’t share a directory between concurrent connections. PGlite is single-process; opening the same directory from two clients at once will conflict.

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.