postgres

package
v0.0.0-...-5106b98 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DialFunc is supplied only by trusted runtime wiring, never by a source payload.
	Authorize         func(context.Context) error `json:"-"`
	MaxConns          int                         `json:"-"`
	DialFunc          pgconn.DialFunc             `json:"-"`
	Host              string                      `json:"host"                      validate:"required,hostname|ip"`
	Port              int                         `json:"port"                      validate:"required,min=1,max=65535"`
	Database          string                      `json:"database"                  validate:"required"`
	SSLMode           string                      `json:"ssl_mode,omitempty"`
	User              string                      `json:"user"                      validate:"required"`
	Password          string                      `json:"password"                  validate:"required"`
	ConnectTimeout    int                         `json:"connect_timeout,omitempty"`
	AllowPrivateHosts bool                        `json:"allow_private_hosts,omitempty"`
}

Config holds configuration for PostgreSQL connections.

type Connector

type Connector struct {
	// contains filtered or unexported fields
}

Connector connects to PostgreSQL databases via pgx.

func New

func New(ctx context.Context, config Config) (*Connector, error)

New creates a new PostgreSQL connector with the provided configuration.

func (*Connector) Close

func (c *Connector) Close() error

Close closes the database connection pool.

func (*Connector) Execute

func (c *Connector) Execute(
	ctx context.Context,
	queryData json.RawMessage,
	params map[string]types.TypedParam,
	limits ...types.ExecutionLimits,
) (*result.ExecutionResult, error)

Execute runs the SQL query described by queryData and returns the results.

func (*Connector) ExecuteStatement

func (c *Connector) ExecuteStatement(
	ctx context.Context,
	stmt string,
	args []any,
) (sqlconnector.Result, error)

ExecuteStatement runs a parameterized SQL statement with ordered positional arguments. Placeholders in stmt must use PostgreSQL $N notation matching the order of args.

func (*Connector) GetCapabilities

func (c *Connector) GetCapabilities() sqlconnector.Capabilities

GetCapabilities returns the capabilities supported by PostgreSQL connector.

func (*Connector) IntrospectSchema

func (c *Connector) IntrospectSchema(ctx context.Context) (*sqlconnector.Schema, error)

IntrospectSchema retrieves the schema of the PostgreSQL database.

func (*Connector) SQLPoolStats

func (c *Connector) SQLPoolStats() stdsql.DBStats

SQLPoolStats returns a safe point-in-time snapshot of the underlying pool.

func (*Connector) TestConnection

func (c *Connector) TestConnection(ctx context.Context) error

TestConnection verifies that a connection to PostgreSQL can be established.

type Credentials

type Credentials struct {
	Username string `json:"username" validate:"required"`
	Password string `json:"password" validate:"required"`
}

Credentials holds PostgreSQL authentication values.

type TableMetadataObserver

type TableMetadataObserver struct {
	sqlconnector.TableMetadataResource
}

func (TableMetadataObserver) AssessMetadata

func (TableMetadataObserver) Description

func (o TableMetadataObserver) Description() string

func (TableMetadataObserver) MatchesResource

func (o TableMetadataObserver) MatchesResource(config, operation json.RawMessage, source bool) bool

func (TableMetadataObserver) Plan

func (TableMetadataObserver) ReadMetadata

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL