PostgreSQL Driver#
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.
Note
This project is not affiliated with PostgreSQL in any way.
Status#
The PostgreSQL driver is experimental. Performance/optimization and support for complex types and different ADBC features is still ongoing.
Installation#
The PostgreSQL driver is shipped as a standalone library.
See Contributing to build and install the package from source.
pip install adbc_driver_postgresql
Usage#
To connect to a database, supply the “uri” parameter when constructing
the AdbcDatabase
. This should be a connection URI.
#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
Supported Features#
Bulk Ingestion#
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.
Performance#
The driver makes use of COPY and the binary format to speed up result set reading. Formal benchmarking is forthcoming.
Transactions#
Transactions are supported.
Type Support#
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.