db

package
v0.0.0-...-7ba27d6 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MySQLDriver = "mysql"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DBConfig

type DBConfig struct {
	Driver   string `json:"driver"`
	Host     string `json:"host"`
	Port     int64  `json:"port"`
	User     string `json:"user"`
	Password string `json:"password"`
	Database string `json:"database"`
	Schema   string `json:"schema"`
	Charset  string `json:"charset"`
	SSLMode  string `json:"sslMode"`
}

DbConfig - dsn info for mysql database connection

func (*DBConfig) CheckValid

func (dbc *DBConfig) CheckValid() (err error)

func (*DBConfig) GenerateDSN

func (dbc *DBConfig) GenerateDSN() (connStr string, err error)

DSN - connStr for connect to db

* - postgres: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING

func (*DBConfig) GetConn

func (dbc *DBConfig) GetConn() (db *sql.DB, err error)

GetConn - get db connection using DbConfig

func (*DBConfig) GetORMConn

func (dbc *DBConfig) GetORMConn() (db *gorm.DB, err error)

GetORMConn - get db connection using DbConfig

Jump to

Keyboard shortcuts

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