Description
Changelog
Reviews (0)

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(), and batch_execute() methods for startup migrations and CLI tools.
  • Connection Pooling: Built-in deadpool-postgres pool 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 like TEXT[], INT4[]).
  • ACID Transactions (PostgresTransaction): Sync and async transactions with an automatic ROLLBACK safety 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): Supports disable, prefer, require, and verify-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, transactions
  • PostgresResult (RefCounted) — ok, rows, columns, affected_rows, first(), scalar(), SQLSTATE error_code
  • PostgresTask (RefCounted) — Awaitable async handle (completed signal)
  • PostgresTransaction (RefCounted) — Isolated ACID transaction with auto-rollback on drop
  • PostgresListener (Node) — Dedicated LISTEN / NOTIFY subscriber

Installation

  1. Download and extract the addon into your Godot project root so addons/godot_postgresql/ is next to project.godot.
  2. Restart the Godot Editor — all classes load automatically via godot_postgresql.gdextension.

Links & Documentation

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.

Reviews

godot-postgresql has no reviews yet.

Login to write a review.

Consider supporting the creators!

If you enjoyed this asset consider supporting its creator. Follow the link below.