postgres

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(cfg Config) (*sqlx.DB, error)

Connect creates a connection to the PostgreSQL instance

func MigrateDB

func MigrateDB(db *sqlx.DB, migrations migrate.MemoryMigrationSource) error

MigrateDB applies any unapplied database migrations

func Setup

func Setup(prefix string, migrations migrate.MemoryMigrationSource) (*sqlx.DB, error)

Setup creates a connection to the PostgreSQL instance and applies any unapplied database migrations. A non-nil error is returned to indicate failure.

func SetupDB

func SetupDB(cfg Config, migrations migrate.MemoryMigrationSource) (*sqlx.DB, error)

SetupDB creates a connection to the PostgreSQL instance and applies any unapplied database migrations. A non-nil error is returned to indicate failure.

func SetupWithConfig

func SetupWithConfig(prefix string, migrations migrate.MemoryMigrationSource, defConfig Config) (*sqlx.DB, error)

SetupWithConfig creates a connection to the PostgreSQL instance and applies any unapplied database migrations. A non-nil error is returned to indicate failure.

Types

type Config

type Config struct {
	Host        string `env:"TIMESCALE_HOST"            envDefault:"localhost"`
	Port        string `env:"TIMESCALE_PORT"            envDefault:"5432"`
	User        string `env:"TIMESCALE_USER"            envDefault:"postgres"`
	Pass        string `env:"TIMESCALE_PASSWORD"        envDefault:"password"`
	Name        string `env:"TIMESCALE_DB_NAME"         envDefault:"postgres"`
	SSLMode     string `env:"TIMESCALE_SSL_MODE"        envDefault:"disable"`
	SSLCert     string `env:"TIMESCALE_SSL_CERT"        envDefault:""`
	SSLKey      string `env:"TIMESCALE_SSL_KEY"         envDefault:""`
	SSLRootCert string `env:"TIMESCALE_SSL_ROOT_CERT"   envDefault:""`
}

Config defines the options that are used when connecting to a TimescaleSQL instance

func (*Config) LoadEnv

func (c *Config) LoadEnv(prefix string) error

Jump to

Keyboard shortcuts

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