common

package
v0.0.0-...-51c5060 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: CC0-1.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DBInit

func DBInit(dbConfig *DBConfig) (*gorm.DB, error)

DBInit is a generic helper function that will try to connect to a database with the config in the input. Supported DB types: * postgres * mysql * sqlite3

Types

type DBConfig

type DBConfig struct {
	DbType   string `yaml:"db_type" validate:"required"`
	URL      string `yaml:"url" validate:"required"`
	Username string `yaml:"username" validate:"required"`
	Password string `yaml:"password" validate:"required"`
	DbName   string `yaml:"db_name" validate:"required"`
	Sslmode  string `yaml:"ssl_mode" validate:"required"`
	Port     int64  `yaml:"port" validate:"required"` // Is int64 to match the type that rds.Endpoint.Port is in the AWS RDS SDK.
}

DBConfig holds configuration information to connect to a database. Parameters for the config.

  • dbname - The name of the database to connect to
  • user - The user to sign in as
  • password - The user's password
  • host - The host to connect to. Values that start with / are for unix domain sockets. (default is localhost)
  • port - The port to bind to. (default is 5432)
  • sslmode - Whether or not to use SSL (default is require, this is not the default for libpq) Valid SSL modes:
  • disable - No SSL
  • require - Always SSL (skip verification)
  • verify-full - Always SSL (require verification)

Jump to

Keyboard shortcuts

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