Skip to content

omni_sqlite

Embedded SQLite

omnigres · Embedded SQLite

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
2969omni_sqliteomnigres0.2.2FEATApache-2.0C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d--NoYesNoYesnono

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY0.2.219 18 17 16 15omnigres-
RPMPIGSTY2026021219 18 17 16 15omnigres_$vpostgresql$v-contrib, postgresql$v-plpython3, python3-pip
DEBPIGSTY2026021219 18 17 16 15postgresql-$v-omnigrespostgresql-plpython3-$v, python3-pip
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el8.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el9.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el9.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el10.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el10.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d12.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d12.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d13.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d13.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u22.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u22.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u24.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u24.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u26.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u26.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212

Source

pig build pkg omnigres;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install omnigres;		# install by package name
pig install omni_sqlite;		# install by extension name

pig install omni_sqlite -v 18;   # install for PG 18
pig install omni_sqlite -v 17;   # install for PG 17
pig install omni_sqlite -v 16;   # install for PG 16
pig install omni_sqlite -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION omni_sqlite;

Usage

omni_sqlite: Embedded SQLite

The omni_sqlite extension provides SQLite databases as a first-class PostgreSQL data type. It is a templated extension.

Create an SQLite Database

SELECT 'CREATE TABLE user_config (key text, value text)'::omni_sqlite.sqlite;

Store SQLite in a Column

CREATE TABLE customer (
    id   bigserial PRIMARY KEY,
    name text NOT NULL,
    data omni_sqlite.sqlite DEFAULT 'CREATE TABLE user_config (key text, value text);'
);

Execute Statements

UPDATE customer
SET data = omni_sqlite.sqlite_exec(data,
    $$INSERT INTO user_config VALUES ('color', 'blue')$$)
RETURNING *;

With bound parameters:

SELECT omni_sqlite.sqlite_exec('CREATE TABLE tab (val text)',
    'INSERT INTO tab VALUES ($1)', row('hello'));

Query SQLite Data

SELECT * FROM omni_sqlite.sqlite_query(
    (SELECT data FROM customer),
    'SELECT rowid, key, value FROM user_config')
AS (id bigint, key text, value text);

Serialization

-- Serialize to bytea:
SELECT omni_sqlite.sqlite_serialize('CREATE TABLE foo (x)');
-- Deserialize from bytea:
SELECT omni_sqlite.sqlite_deserialize(bytea_data);

Useful for multitenancy (isolated SQLite databases per row) and peer synchronization.

Table reader