The PostgreSQL driver provides access to any database that supports the PostgreSQL wire format. It wraps libpq, the client library for PostgreSQL. The project owes credit to 0x0L’s pgeon for the overall approach.
This project is not affiliated with PostgreSQL in any way.
The PostgreSQL driver is experimental. Performance/optimization and support for complex types and different ADBC features is still ongoing.
The PostgreSQL driver is shipped as a standalone library.
See Contributing to build and install the package from source.
pip install adbc_driver_postgresql
#include "adbc.h" // Ignoring error handling struct AdbcDatabase database; AdbcDatabaseNew(&database, nullptr); AdbcDatabaseSetOption(&database, "uri", "postgresql://localhost:5433", nullptr); AdbcDatabaseInit(&database, nullptr);
import adbc_driver_postgresql.dbapi uri = "postgresql://localhost:5433" with adbc_driver_postgresql.dbapi.connect(uri) as conn: pass
Bulk ingestion is supported. The mapping from Arrow types to PostgreSQL types is the same as below.
Partitioned Result Sets#
Partitioned result sets are not supported.
The driver makes use of COPY and the binary format to speed up result set reading. Formal benchmarking is forthcoming.
Transactions are supported.
PostgreSQL allows defining new types at runtime, so the driver must build a mapping of available types. This is currently done once at startup.
Type support is currently limited. Parameter binding and bulk ingestion support int16, int32, int64, and string. Reading result sets is limited to int32, int64, float, double, and string.