postgresql

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MPL-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PGResourceExistsFunc

func PGResourceExistsFunc(fn func(*DBConnection, *schema.ResourceData) (bool, error)) func(*schema.ResourceData, any) (bool, error)

func PGResourceFunc

func PGResourceFunc(fn func(*DBConnection, *schema.ResourceData) error) func(*schema.ResourceData, any) error

func Provider

func Provider() *schema.Provider

Provider returns a terraform.ResourceProvider.

Types

type Client

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

Client struct holding connection string

func (*Client) Connect

func (c *Client) Connect() (*DBConnection, error)

Connect returns a copy to an sql.Open()'ed database connection wrapped in a DBConnection struct. Callers must return their database resources. Use of QueryRow() or Exec() is encouraged. Query() must have their rows.Close()'ed.

type ClientCertificateConfig

type ClientCertificateConfig struct {
	CertificatePath string
	KeyPath         string
	SSLInline       bool
}

type Config

type Config struct {
	Scheme                          string
	Host                            string
	Port                            int
	Username                        string
	Password                        string
	DatabaseUsername                string
	Superuser                       bool
	SSLMode                         string
	ApplicationName                 string
	Timeout                         int
	ConnectTimeoutSec               int
	MaxConns                        int
	ExpectedVersion                 semver.Version
	SSLClientCert                   *ClientCertificateConfig
	SSLRootCertPath                 string
	GCPIAMImpersonateServiceAccount string
}

Config - provider config

func (*Config) NewClient

func (c *Config) NewClient(database string) *Client

NewClient returns client config for the specified database.

type DBConnection

type DBConnection struct {
	*sql.DB
	// contains filtered or unexported fields
}

type PGFunction

type PGFunction struct {
	Schema          string
	Name            string
	Returns         string
	Language        string
	Body            string
	Args            []PGFunctionArg
	Parallel        string
	SecurityDefiner bool
	Strict          bool
	Volatility      string
}

PGFunction is the model for the database function

func (*PGFunction) FromResourceData

func (pgFunction *PGFunction) FromResourceData(d *schema.ResourceData) error

func (*PGFunction) Parse

func (pgFunction *PGFunction) Parse(functionDefinition string) error

type PGFunctionArg

type PGFunctionArg struct {
	Name    string
	Type    string
	Mode    string
	Default string
}

func (*PGFunctionArg) Parse

func (pgFunctionArg *PGFunctionArg) Parse(functionArgDefinition string) error

type QueryAble

type QueryAble interface {
	Exec(query string, args ...any) (sql.Result, error)
	Query(query string, args ...any) (*sql.Rows, error)
	QueryRow(query string, args ...any) *sql.Row
}

QueryAble is a DB connection (sql.DB/Tx)

type ResourceSchemeGetter

type ResourceSchemeGetter func(string) any

Jump to

Keyboard shortcuts

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