postgresdb

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: Apache-2.0 Imports: 4 Imported by: 18

Documentation

Index

Constants

View Source
const DateFormatString = "2006/01/02"

DateFormatString is the format to be used when converting a timestamp to a date

View Source
const TimestampFormatString = "2006/01/02 15:04:05 MST"

TimestampFormatString is the format to be used when inserting timestamps in the database

Variables

This section is empty.

Functions

func CreateDatabaseIfNotExists

func CreateDatabaseIfNotExists(postgresDbConfig *Config) (bool, error)

CreateDatabaseIfNotExists returns whether the db was created and an error if creation failed

func ExecuteStatement

func ExecuteStatement(db *sql.DB, sqlStatement string) error

ExecuteStatement runs a statement that does not return a result

Types

type Config

type Config struct {
	Host      string `toml:"HOST"`
	Port      uint16 `toml:"PORT"`
	DbName    string `toml:"DB_NAME"`
	User      string `toml:"USER"`
	Password  string `toml:"PASSWORD"`
	SSLEnable bool   `toml:"SSL_ENABLE"`
}

Config takes in the information needed to connect to a postgres database

func (*Config) GetDbName

func (c *Config) GetDbName() string

GetDbName returns the name of the database after defaulting if needed

func (*Config) GetHost

func (c *Config) GetHost() string

GetHost returns the host of the database after defaulting if needed

func (*Config) GetPassword

func (c *Config) GetPassword() string

GetPassword returns the password to the database, no defaulting

func (*Config) GetPort

func (c *Config) GetPort() uint16

GetPort returns the port of the database after defaulting if needed

func (*Config) GetSSLMode

func (c *Config) GetSSLMode() string

GetSSLMode returns the sslmode string to the database after converting the input boolean value

func (*Config) GetUser

func (c *Config) GetUser() string

GetUser returns the username to the database, no defaulting

func (*Config) MakeConnectString

func (c *Config) MakeConnectString() string

MakeConnectString returns the string to be used to open this db

func (*Config) MakeConnectStringWithoutDB

func (c *Config) MakeConnectStringWithoutDB() string

MakeConnectStringWithoutDB returns the string to be used when connecting to a postgres instance without a database

Jump to

Keyboard shortcuts

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