postgres

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

README


title: 'PostgreSQL'

PostgreSQL connector allows querying PostgreSQL databases.

Config Schema

Field Type Required Description
type string yes constant: postgres
hosts string[] yes List of database hosts
database string yes Database name
user string yes Username
password string yes Password
port integer yes TCP port (default 5432)
schema string no instead of "public" it could be custom
tls_file string no PEM-encoded certificate for TLS
enable_tls boolean no Enable TLS/SSL connection
conn_string string no DSN-like connection string

Config example:

type: postgres
hosts: 
  - localhost
database: mydb
user: postgres
password: secret
port: 5432
schema: sales
tls_file: ""        # Optional PEM-encoded certificate
enable_tls: false   # Enable TLS/SSL connection 

Or as alternative with plain DSN:

type: postgres
conn_string: postgresql://my_user:my_pass@localhost:5432/mydb

Deploy PostgreSQL Sample Databases

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Hosts      []string `yaml:"hosts"`
	Database   string   `yaml:"database"`
	User       string   `yaml:"user"`
	Password   string   `yaml:"password"`
	Port       int      `yaml:"port"`
	TLSFile    string   `yaml:"tls_file"`
	EnableTLS  bool     `yaml:"enable_tls"`
	ConnString string   `yaml:"conn_string"` // Connection string in format: postgresql://user:password@host:port/database
	Schema     string   `yaml:"schema"`      // Database schema name for table access (format: schema.table_name)
}

func (Config) Doc

func (c Config) Doc() string

func (Config) ExtraPrompt added in v0.0.8

func (c Config) ExtraPrompt() []string

func (Config) MakeConfig

func (c Config) MakeConfig() (*pgx.ConnConfig, error)

func (Config) TLSConfig

func (c Config) TLSConfig() (*tls.Config, error)

func (Config) Type

func (c Config) Type() string

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface to allow for both direct connection string or full configuration objects in YAML

type Connector

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

Connector implements the connectors.Connector interface for PostgreSQL

func (Connector) Config added in v0.0.8

func (c Connector) Config() connectors.Config

func (Connector) Discovery

func (c Connector) Discovery(ctx context.Context) ([]model.Table, error)

func (*Connector) GuessColumnType

func (c *Connector) GuessColumnType(sqlType string) model.ColumnType

GuessColumnType implements TypeGuesser interface for PostgreSQL

func (*Connector) InferQuery

func (c *Connector) InferQuery(ctx context.Context, query string) ([]model.ColumnSchema, error)

InferQuery implements the Connector interface

func (*Connector) InferResultColumns

func (c *Connector) InferResultColumns(ctx context.Context, query string) ([]model.ColumnSchema, error)

InferResultColumns returns column information for the given query

func (Connector) LoadsColumns

func (c Connector) LoadsColumns(ctx context.Context, tableName string) ([]model.ColumnSchema, error)

func (Connector) Ping

func (c Connector) Ping(ctx context.Context) error

func (Connector) Query

func (c Connector) Query(ctx context.Context, endpoint model.Endpoint, params map[string]any) ([]map[string]any, error)

func (Connector) Sample

func (c Connector) Sample(ctx context.Context, table model.Table) ([]map[string]any, error)

Jump to

Keyboard shortcuts

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