Source File
doc.go
Belonging Package
github.com/jackc/pgx/v5/pgconn
// Package pgconn is a low-level PostgreSQL database driver./*pgconn provides lower level access to a PostgreSQL connection than a database/sql or pgx connection. It operates atnearly the same level is the C library libpq.Establishing a ConnectionUse Connect to establish a connection. It accepts a connection string in URL or keyword/value format and will read theenvironment for libpq style environment variables.Connecting SecurelyBy default ParseConfig matches libpq and uses sslmode=prefer, which silently falls back to an unencrypted connectionif the server does not offer TLS. For connections that traverse an untrusted network, set the following parametersexplicitly:# URL formpostgres://user@db.example.com/mydb?sslmode=verify-full&sslrootcert=/path/to/root.crt&channel_binding=require&require_auth=scram-sha-256# keyword/value formhost=db.example.com user=user dbname=mydb sslmode=verify-full sslrootcert=/path/to/root.crt channel_binding=require require_auth=scram-sha-256sslmode=verify-full Require TLS, verify the server certificate against sslrootcert, and verify that thecertificate's host name matches the host being connected to. Weaker modes (disable,allow, prefer, require) either permit plaintext fallback or skip certificateverification, allowing a network attacker to impersonate the server.channel_binding=require Require SCRAM-SHA-256-PLUS, which binds the authentication exchange to the TLS channelso that a TLS-terminating intermediary cannot relay credentials to the real server.require_auth=scram-sha-256Refuse to respond to AuthenticationCleartextPassword or AuthenticationMD5Passwordrequests from the server. Without this, a server (or interceptor) can request thepassword in cleartext and the client will send it.These parameters may also be set via the PGSSLMODE, PGSSLROOTCERT, PGCHANNELBINDING, and PGREQUIREAUTH environmentvariables.Executing a QueryExecParams and ExecPrepared execute a single query. They return readers that iterate over each row. The Read methodreads all rows into memory.Executing Multiple Queries in a Single Round TripExec and ExecBatch can execute multiple queries in a single round trip. They return readers that iterate over each queryresult. The ReadAll method reads all query results into memory.Pipeline ModePipeline mode allows sending queries without having read the results of previously sent queries. It allows control ofexactly how many and when network round trips occur.Context SupportAll potentially blocking operations take a context.Context. The default behavior when a context is canceled is for themethod to immediately return. In most circumstances, this will also close the underlying connection. This behavior canbe customized by using BuildContextWatcherHandler on the Config to create a ctxwatch.Handler with different behavior.This can be especially useful when queries that are frequently canceled and the overhead of creating new connections isa problem. DeadlineContextWatcherHandler and CancelRequestContextWatcherHandler can be used to introduce a delay beforeinterrupting the query in such a way as to close the connection.The CancelRequest method may be used to request the PostgreSQL server cancel an in-progress query without forcing theclient to abort.*/package pgconn
The pages are generated with Golds v0.8.4. (GOOS=linux GOARCH=amd64)