db

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: MIT Imports: 4 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDb

func CloseDb() (err error)

CloseDb closes the connection to MySQL

func GetDb

func GetDb() (*sql.DB, error)

GetDb returns a connection to MySQL

func GetTransaction

func GetTransaction() (*sql.Tx, error)

GetTransaction will return a transaction

func NewTestDb added in v1.3.0

func NewTestDb() (mock sqlmock.Sqlmock, err error)

NewTestDb gets a database mock for testing

Types

type Database

type Database struct {
	// Database connection settings
	User           string
	Password       string
	Proto          string
	Host           string
	Database       string
	MaxIdle        int
	MaxConnections int
}

Database holds the connection options

func (*Database) NewDb

func (d *Database) NewDb()

NewDb initializes a connection to MySQL and tries to connect.

Jump to

Keyboard shortcuts

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