230 of 230 Flagsmith engine tests passRun them

Flagsmith’s flag engine, written in SQL

pgsmith is a Postgres extension that gives the same answers as Flagsmith’s SDKs, so a query or a row-level security policy can check a flag without leaving the database. This page has downloaded PostgreSQL 19, compiled to WebAssembly, and installed the pgsmith 0.1.0 release into it.

Putting pgsmith on your own database

  1. Install the release

    On Supabase and Amazon RDS, pipe the release’s pg_tle installer into psql. On any other PostgreSQL from 14 to 18, build the extension and run CREATE EXTENSION.

  2. Point it at Flagsmith

    A small sync service listens for Flagsmith’s webhooks. On Supabase you can skip the service: pg_cron fetches the environment document from inside the database, with the key kept in Vault.

  3. Read flags in SQL

    Your queries call pgsmith in the same statement that reads your tables, so checking a flag never goes over the network.

What is real on this page

Most of it. The data is made up, and a few things a browser can’t do are done another way. The list fills in as the database starts.

Database
Starting…
pgsmith
The 0.1.0 release file, unchanged apart from two lines that only work inside CREATE EXTENSION.
Test cases
Fetched from Flagsmith/engine-test-data v3.13.2 through jsDelivr when you press Run on the Tests page. Nothing is bundled.
Flagsmith’s engine
The Tests page can download flagsmith-flag-engine 11.1.2 from PyPI and run it with Pyodide, Python compiled to WebAssembly.
Flagsmith’s API
The Flagsmith page calls it straight from your browser. Your key stays in memory and goes only to the URL you type.
Made up
The 10,000 users in app.users, and the Production and Staging environments, which were exported from a Flagsmith we ran locally.
Not here
PGlite is single-user and has no background workers, so pg_cron sync can’t run. The Flagsmith page polls from the browser instead.