supabase
The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
- 115k
- TypeScript
- Apache-2.0
- 6 min ago
Native PostgreSQL client for D: pure-D blocking (Phobos) and fiber (vibe.d) I/O
Repo buggins/postgresql-native, read from GitHub 16 h ago. buggins has not joined Take My Repo.
buggins/postgresql-native is a public repo on GitHub by buggins. Native PostgreSQL client for D: pure-D blocking (Phobos) and fiber (vibe.d) I/O. It declares the BSL-1.0 license on GitHub. It is written mainly in D, has 0 stars and last changed on 2026-11-18. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-23.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
A native client for PostgreSQL in D: the PostgreSQL frontend/backend protocol over TCP, written in pure D, for ordinary threads (blocking sockets) and vibe.d fibers. No libpq, no C libraries at build time.
Status: 0.6.2. The API may still change before 1.0; the plan is tracked in the roadmap issue, changes in the changelog.
Add it to your dub.json:
"dependencies": {
"postgresql-native": "~>0.6.2"
}
import postgresql;
import std.stdio;
void main()
{
auto conn = new Connection("postgresql://app:secret@localhost/sales");
// or "host=localhost dbname=sales user=app", or fromEnvironment() for the PG* variables
scope (exit)
conn.close();
conn.exec("CREATE TABLE notes (id int PRIMARY KEY, text text)");
conn.exec("INSERT INTO notes VALUES (?, ?)", 1, "first");
foreach (row; conn.query("SELECT id, text FROM notes WHERE id >= $1 ORDER BY id", 1))
writeln(row.getInt(0), " ", row.getString("text"));
}
Features:
require_auth; TLS with certificate verification, client certificates,
libpq's sslmode values and PostgreSQL 17's direct TLS;postgresql:// URIs and key=value) with
libpq's keywords, the PG* environment variables, the password file
(~/.pgpass), the default TLS files in ~/.postgresql; several hosts with
failover, target_session_attrs and load_balance_hosts;$1, $2, … or ?), binary formats, a statement
cache, prepared statements, several result sets, transactions and
savepoints, cancellation, statement_timeout, notices, pipelines;numeric (as exact decimals), text, bytea, bool, date,
time, timetz, timestamp and timestamptz (with microseconds),
interval, uuid, json/jsonb, arrays (any dimensions), ranges and
multiranges, composite types, enums, domains, inet/cidr,
macaddr/macaddr8, bit/varbit, the geometric types, pg_lsn, and
the extension types hstore, citext and PostGIS geometry/geography;
the others (money, xml, tsvector, ...) as text;COPY FROM STDIN and COPY TO STDOUT (text, CSV, binary; rows of D values or
structs, streamed), LISTEN/NOTIFY with waiting for notifications;Later: a ddbc driver and hibernated support. GSSAPI, SSPI and Unix-domain sockets are not supported.
It builds on dbwire, the pure-D building blocks shared with clickhoused, mssql-native and oracle-native: transports for threads and fibers, TLS with OpenSSL loaded at run time, cryptography for the password exchange, exact decimals, connection pools.
Requires a D frontend 2.097 or newer (DMD 2.097+, LDC 1.27+).
dub test # unit tests, no server needed
docker run -d --name pgnative-18 -p 15418:5432 -e POSTGRES_USER=testuser \
-e POSTGRES_PASSWORD=Test_password123 -e POSTGRES_DB=testdb postgres:18
POSTGRES_HOST=localhost:15418 POSTGRES_PASSWORD=Test_password123 \
dub run :integration-tests-phobos # or :integration-tests-vibe (vibe-core 2.x), :integration-tests-vibe1 (1.x)
sh integration-tests/setup-server.sh pgnative-18 adds TLS and a user per
authentication method; then set POSTGRES_SETUP=1 to run those tests too.
The socket tests need the container's /var/run/postgresql mounted on the
host (-v /tmp/pgsocket:/var/run/postgresql, a short path: socket paths are
limited to about 100 bytes) and POSTGRES_SOCKET_DIR=/tmp/pgsocket.
See CONTRIBUTING.md.
auto conn = new Connection("postgresql://app@db1:5432,db2:5432/sales?sslmode=verify-full"
~ "&sslrootcert=/etc/ssl/db-ca.pem&target_session_attrs=read-write");
auto conn2 = new Connection("host=db1 dbname=sales user=app application_name=report");
auto conn3 = new Connection(fromEnvironment()); // PGHOST, PGUSER, PGDATABASE, PGSSLMODE, ...
Keywords are libpq's: host (a name, an address, or the directory of the
server's Unix-domain socket, e.g. /var/run/postgresql; @name for a Linux
abstract socket), hostaddr (numeric addresses to connect to,
keeping host for TLS name checks and the password file), port (several,
comma-separated, for failover), service and servicefile (connection services,
pg_service.conf), dbname, user, password, passfile, options,
application_name, connect_timeout, sslmode (disable, allow,
prefer (the default), require, verify-ca, verify-full),
sslnegotiation, sslrootcert (system for the system's store), sslcert,
sslkey, sslpassword, sslcrl, sslcrldir, ssl_min_protocol_version,
ssl_max_protocol_version, channel_binding, require_auth,
max_protocol_version, requirepeer, target_session_attrs (any, read-write,
read-only, primary, standby, prefer-standby), load_balance_hosts
(disable, random); and this library's statement_cache_size,
rewrite_placeholders, io_mode (or io: auto, phobos, vibe). ConnectionOptions has them all as fields,
plus the timeouts, statementTimeout and run-time parameters for the startup
message.
ConnectionOptions.parse reads only the string (and the service file a
service names); fromEnvironment adds the PG* variables, as psql does:
the string's keywords first, then the service's (PGSERVICE), then the
environment's. Service files are the user's (servicefile, PGSERVICEFILE,
else ~/.pg_service.conf) and then the system's (pg_service.conf in
PGSYSCONFDIR, else in /etc/postgresql-common, /etc/sysconfig/pgsql or
/etc). Without a password, one from the password
file is used when the server asks (passfile, PGPASSFILE, else
~/.pgpass; %APPDATA%\postgresql\pgpass.conf on Windows). The TLS files
default to root.crt, root.crl, postgresql.crt and postgresql.key in
~/.postgresql when they exist (postgresql.key with permissions 0600 or
less, as libpq checks); with root.crt, sslmode=require verifies the
certificate. TLS is never used over Unix-domain sockets, and the default
host is localhost over TCP (libpq's default is the socket directory). When no CA is given, verify-full uses the
system's trusted certificates, and verify-ca fails (as in libpq: without the
host name check, any certificate those CAs issued would be accepted).
Without TLS (sslmode=disable, or prefer with a server without TLS), the
session travels in clear; SCRAM still keeps the password itself off the
network.
conn.exec("UPDATE notes SET text = ? WHERE id = ?", "1st", 1); // ? becomes $1, $2
auto r = conn.query("SELECT * FROM notes WHERE id = ANY($1::int[])", "{1,2}");
const n = conn.exec("DELETE FROM notes WHERE text IS NULL"); // simple protocol, rows affected
auto stmt = conn.prepare("INSERT INTO notes VALUES ($1, $2)");
foreach (i; 2 .. 10)
stmt.exec(i, "note");
Values are encoded for the parameter types the server infers from the SQL:
binary when the D type matches the column type (integers, with range checks;
floats; bool; ubyte[] for bytea; Date, TimeOfDay, DateTime,
SysTime, Duration, Interval, UUID), otherwise as text the server
parses (Decimal, strings for any type, json); null and Nullable send
NULL, Variant its value. Integer enums go as their value to numeric
parameters and as their member name to others (text, PostgreSQL enum types).
Add a cast ($1::int8) where the server can't infer a type. ? is rewritten
outside quotes, comments and dollar quotes; write ?? for a literal ?, or
switch the rewriting off (rewrite_placeholders=false) for jsonb's ?
operators.
Statements with parameters are kept prepared per connection, by SQL text
(statement_cache_size, default 100; 0 behind PgBouncer in transaction mode
before 1.21), so running one again takes one round trip.
conn.begin(IsolationLevel.serializable);
conn.exec("INSERT INTO notes VALUES (?, ?)", 20, "x");
conn.savepoint("sp");
conn.rollbackTo("sp");
conn.commit();
// from another thread or vibe.d task: stops the running statement (SQLSTATE 57014)
conn.cancel();
auto p = conn.pipeline(); // one round trip for all
p.add("INSERT INTO notes VALUES (?, ?)", 30, "y");
const q = p.add("SELECT count(*) FROM notes");
auto results = p.run(); // one implicit transaction; PipelineMode.independent: each on its own
writeln(results[q].rows[0].getLong(0));
struct Order
{
int id;
@column("customer_name") string customer;
Decimal amount;
Nullable!DateTime shipped;
Status status; // a D enum: PostgreSQL enum or text by name, integers by value
@ignore string note;
}
conn.insert("orders", orders); // multi-row INSERTs, atomic
foreach (o; conn.query!Order("SELECT * FROM orders WHERE amount > ?", 5))
writeln(o.customer, " ", o.amount);
auto first = conn.queryRow!Order("SELECT * FROM orders WHERE id = ?", 1);
auto total = conn.queryValue!long("SELECT count(*) FROM orders");
Fields map to columns by name (exact, else ignoring case); extra result
columns are ignored. Fields may be arrays (int[], string[][]), ranges
(Range!DateTime), structs (from composite types), Inet, Point, ... —
anything Value.get!T reads. insert writes up to 1000 rows per statement; outside a
transaction block, an insert of several statements runs in a transaction of
its own. Column names that are plain identifiers are folded to lower case, as
PostgreSQL folds unquoted names.
// load: values in text, CSV or binary rows, or bytes as they are
auto copy = conn.copyIn("COPY notes (id, text) FROM STDIN");
copy.writeRow(1, "first\tline"); // escaped as the format needs
copy.writeRow(2, null); // NULL
copy.write("3\tthird\n"); // raw data
const loaded = copy.finish(); // 3 (abort() cancels; nothing is loaded)
conn.copyInsert("orders", orders); // structs, binary COPY: the fastest load
auto bin = conn.copyInto("orders", ["id", "amount"]); // binary rows of values
bin.writeRow(10, Decimal.fromString("9.90"));
bin.finish();
// read: chunks of bytes, or rows
auto csv = conn.copyOut("COPY (SELECT id, text FROM notes) TO STDOUT WITH (FORMAT csv)", CopyFormat.csv);
csv.columnTypes([Oid.int4, Oid.text]); // for typed getters (binary data needs them)
foreach (row; csv)
writeln(row.getInt(0), " ", row.getString(1));
Data is sent in 64 KiB messages; a server error during a load (a bad row,
a constraint) is noticed while writing and thrown, and nothing is loaded.
Binary rows need each value's binary form for its column (copyInto
looks the column types up); numeric, jsonb and text types are converted,
types without one (composite values, ranges) need text or CSV.
listener.listen("events");
other.notify("events", "payload"); // pg_notify, delivered at commit
auto n = listener.waitForNotification(5.seconds); // null on timeout
if (!n.isNull)
writeln(n.get.channel, ": ", n.get.payload);
auto pending = listener.pollNotifications(); // without waiting
listener.onNotification = (Notification x) { ... }; // or as they arrive
Notifications also arrive with the responses to other statements
(takeNotifications). waitForNotification waits on the socket; in fiber mode
other tasks run meanwhile.
auto pool = new ConnectionPool("postgresql://app:secret@db/sales?pool_max=8");
{
auto conn = pool.lockConnection(); // waits while all 8 are in use
conn.exec("UPDATE stats SET hits = hits + 1");
} // back to the pool
The same code runs in threads (blocking sockets) and in vibe.d tasks, where
waiting for the server suspends only the task: the I/O mode follows the
caller (ConnectionOptions.ioMode). A returned connection gets its session
reset (Connection.resetSession: an open transaction rolled back, settings,
temporary tables, advisory locks and LISTENs cleared) while its prepared
statements stay. Pool keywords: pool_max, pool_wait_timeout,
pool_max_idle_time, pool_max_lifetime, pool_ping_after_idle. See
examples/ (dub run :example-basic, dub run :example-vibe).
Row getters convert a column to D types (getLong, getInt, getBool,
getDouble, getDecimal, getString, getBytes, getDate,
getTimeOfDay, getDateTime, getSysTime, getMicrosecondsOfSecond,
getDuration, getInterval, getUUID, getInet, getBitString,
getArray, getRange, getMultirange, getRecord, getHstore,
getVariant), by index or column name, and get!T converts to any
supported D type (row.get!(int[])(0), row.get!(Range!Date)("during"),
row.get!Address("home"), row.get!(Nullable!long)(1)). NULL throws,
except for getString, getBytes, getVariant and types that hold it
(isNull tells).
| PostgreSQL type | D type | Notes |
|---|---|---|
int2, int4, int8, oid |
short, int, long, uint |
|
numeric |
Decimal (exact, 76 digits) |
NaN, infinities and longer values: getString |
float4, float8 |
float, double |
text: shortest exact, as the server writes it |
text, varchar, char(n), name |
string |
UTF-8 |
bytea |
ubyte[] |
text: \x… hexadecimal |
bool |
bool |
text t / f |
date |
Date |
infinities: getString |
time / timetz |
TimeOfDay / string |
microseconds with getMicrosecondsOfSecond |
timestamp |
DateTime |
microseconds with getMicrosecondsOfSecond, getSysTime (UTC) |
timestamptz |
SysTime |
text in the session's TimeZone |
interval |
Interval (months, days, microseconds) |
getDuration when it has no months |
uuid |
UUID |
|
json, jsonb |
string |
the server's text |
arrays (int4[], text[][], ...) |
get!(T[]), nested for more dimensions; getArray |
NULL elements: Nullable!T[]; lower bounds kept |
| ranges, multiranges (14+) | get!(Range!T), get!(Range!T[]); getRange |
int4range, int8range, numrange, daterange, tsrange, tstzrange, user ranges |
composite types, record |
get!S for a struct; getRecord |
fields by name for named types, in order for record |
| enums | string, or a D enum by member name |
|
| domains | as their base type | |
inet, cidr |
Inet |
|
macaddr, macaddr8 |
ubyte[] (getBytes) |
|
bit, varbit |
BitString |
|
point, line, lseg, box, path, polygon, circle |
Point, Line, LineSegment, Box, Path, Polygon, Circle |
|
pg_lsn |
get!ulong |
|
hstore (extension) |
string[string], Nullable!string[string]; getHstore |
|
citext (extension) |
string |
|
PostGIS geometry, geography |
ubyte[] (EWKB, getBytes) |
text: its hexadecimal digits |
money, xml, tsvector, tsquery, others |
string |
the server's text |
getString gives exactly the text PostgreSQL prints for every type.
getVariant holds the first D type listed for scalar types, and the text
of arrays, ranges, composite values and the types read as text. The client looks up the types of the database (enums, composite types,
domains, their arrays and ranges, extension types) in pg_type the first
time a statement meets them, once per connection (clearTypeCache after
ALTER TYPE); querySimple results use the types already known.
The same D types work as parameters: D arrays (binary for arrays of built-in
types), Range!T, structs (composite values), string[string] (hstore),
Inet, BitString, the geometric structs; PostGIS values as text (WKT or
hex EWKB) or through ST_GeomFromWKB(?) with ubyte[]. Time
zones use the system's time zone database (Windows has none: timestamptz
text then shows UTC).
This is an unofficial project, not affiliated with, endorsed or sponsored by the PostgreSQL Global Development Group. "PostgreSQL" and "Postgres" are trademarks of the PostgreSQL Community Association of Canada. The client is an independent implementation of the publicly documented PostgreSQL frontend/backend protocol.
buggins/postgresql-native is a public repo on GitHub by buggins. Native PostgreSQL client for D: pure-D blocking (Phobos) and fiber (vibe.d) I/O.
It declares the BSL-1.0 license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2026-11-18. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

A fast PostgreSQL Database Client Library for Python/asyncio.

Run compilers interactively from your web browser and interact with the assembly
Stop renting your intelligence. Own it with AnythingLLM. Everything you need for a powerful local-first agent experience
Full-stack observability · Metrics · Logs · Traces · Flows · Topology · Infrastructure · APM · NPM · DBM · RUM · Synthetics · Cloud · AI SRE · OpenTelemetry · SNMP · NetFlow/IPFIX/sFlow · IPMI · Redfish · 2000+ integrations
Official site of CoolReader project. Sourceforge repository is obsolete.

This page is also available as structured data, with the same sources and dates.
/api/v1/resources/gh/buggins/postgresql-nativeTake My Repo has not tested this on your machine. Requirements come from the project's own documentation.