GodotPostgreSQL is a high-performance, self-contained native PostgreSQL GDExtension for Godot 4.2+ (GDScript) written in Rust (gdext, tokio-postgres, deadpool-postgres, and rustls).
It ships as a single prebuilt binary per platform for Windows (x86_64) and Linux (x86_64) — working out of the box in the Godot Editor, Desktop Exports, and Headless Dedicated Servers (--headless) with zero external runtime dependencies (no libpq.dll, no system OpenSSL, and no VC++ Redistributable required).
Key Features
- Built for GDScript: Works directly with the standard (non-.NET) Godot 4 build.
- Non-Blocking Async Queries (
await): Backed by a multi-threaded Tokio runtime so database queries never block the Godot main thread or dedicated server tick loop. - Synchronous API Included: Blocking
query(),execute(), andbatch_execute()methods for startup migrations and CLI tools. - Connection Pooling: Built-in
deadpool-postgrespool with configurable pool size, timeouts, and live metrics (get_pool_status()). - Automatic Type Mapping & SQL Injection Protection: Uses cached prepared statements (
prepare_cached) with$1, $2, ...placeholders and seamless conversion between GDScript (int,float,bool,String,Dictionary,Array,PackedByteArray,null) and PostgreSQL (INT2/4/8,FLOAT4/8,NUMERIC,TEXT,BYTEA,JSON/JSONB,UUID,TIMESTAMP/TIMESTAMPTZ,DATE,TIME,ENUM, and arrays likeTEXT[],INT4[]). - ACID Transactions (
PostgresTransaction): Sync and async transactions with an automaticROLLBACKsafety net if dropped before committing. - Real-Time
LISTEN / NOTIFY(PostgresListener): Cross-server pub/sub messaging for multi-instance headless Godot game servers. - Built-in TLS / SSL (
rustls): Supportsdisable,prefer,require, andverify-full(including custom PEM root CA certificates) for Supabase, Neon, AWS RDS, Render, and self-hosted PostgreSQL.
Quick Example (GDScript)
var db := PostgresClient.new()
add_child(db)
var conn: PostgresResult = await db.connect_url_async(
"postgresql://postgres:[email protected]:5432/gamedb?sslmode=prefer",
{ "max_pool_size": 16 }
).completed
if conn.ok:
var res: PostgresResult = await db.query_async(
"SELECT id, username, coins FROM players WHERE level >= $1 LIMIT $2",
[10, 5]
).completed
if res.ok:
for row: Dictionary in res.rows:
print(row["username"], ": ", row["coins"])
Exposed Classes
PostgresClient(Node) — Connection pool, sync/async queries, batch execution, transactionsPostgresResult(RefCounted) —ok,rows,columns,affected_rows,first(),scalar(), SQLSTATEerror_codePostgresTask(RefCounted) — Awaitable async handle (completedsignal)PostgresTransaction(RefCounted) — Isolated ACID transaction with auto-rollback on dropPostgresListener(Node) — DedicatedLISTEN / NOTIFYsubscriber
Installation
- Download and extract the addon into your Godot project root so
addons/godot_postgresql/is next toproject.godot. - Restart the Godot Editor — all classes load automatically via
godot_postgresql.gdextension.
Links & Documentation
- GitHub Repository: https://github.com/mthnzbk/godot-postgresql
- Full Tutorial (EN): https://github.com/mthnzbk/godot-postgresql/blob/main/docs/TUTORIAL.md
- Detaylı Rehber (TR): https://github.com/mthnzbk/godot-postgresql/blob/main/docs/TUTORIALtr.md
- License: MIT
Security Note: Direct PostgreSQL connections are intended for trusted Godot Dedicated Servers (
--headless) and internal/local tools. Do not embed database credentials inside distributed client builds.
Changelog for version 1.0
2026-11-28 21:40:44
No changelog provided for this version.