Home

libpq

libpq is the C client application programming interface for PostgreSQL. It is distributed as part of the PostgreSQL project and provides the primary means for applications to connect to PostgreSQL servers, issue SQL commands, and obtain query results.

Key capabilities include connection management (establishing and maintaining a database session, with statuses accessible via PQstatus),

Query execution and results are handled through high-level functions like PQexec, PQexecParams, and PQprepare for prepared

libpq provides data transfer features for large objects and the COPY protocol, including functions for COPY

Security and platform support: libpq supports SSL/TLS, GSSAPI/SSPI authentication, Kerberos, and certificate verification. It runs on

License and ecosystem: libpq is released under the PostgreSQL License, a liberal open-source license. It is

authentication,
and
optional
TLS/SSL
encryption.
The
library
supports
both
blocking
and
non-blocking
operation,
using
functions
such
as
PQconnectdb,
PQconnectdbParams,
PQsendQuery,
and
PQgetResult.
statements.
Results
are
represented
by
PGresult
objects,
with
accessors
such
as
PQntuples,
PQnfields,
PQfname,
and
PQgetvalue.
Error
reporting
is
available
via
PQresultErrorMessage,
and
resources
are
freed
with
PQclear.
operations
and
binary
data
transfer.
It
supports
transparent
type
conversion
and
binary
transfer
when
requested,
and
offers
an
asynchronous
API
alongside
the
traditional
synchronous
style.
major
Unix-like
systems
and
Windows,
and
is
designed
to
be
portable
across
platforms.
The
library
handles
encoding
conversions
and
error
reporting
in
a
consistent
way
to
simplify
client
development.
the
standard
C
interface
used
by
many
PostgreSQL
client
libraries
and
tools;
language
bindings
exist
for
other
languages
but
often
rely
on
libpq
for
low-level
communication.
Compatibility
is
generally
aligned
with
corresponding
PostgreSQL
server
versions.