msql

package
v1.11.13 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package msql creates connections to MySQL datastores.

Index

Constants

View Source
const (
	// Protocol of the database driver.
	Protocol = "tcp"
	// DriverName of the database.
	DriverName = "mysql"
	// Timeout default in seconds for a database connection.
	Timeout = 30
)

Variables

View Source
var (
	ErrConfig   = errors.New("no connection configuration was provided")
	ErrConnect  = errors.New("no connection to the mysql database server")
	ErrDB       = errors.New("database handle pointer cannot be nil")
	ErrDatabase = errors.New("name of the database to connect is missing")
	ErrTimeout  = errors.New("connection timeout is too short")
	ErrHost     = errors.New("host name of the database server is missing")
	ErrUser     = errors.New("user for database login is missing")
)

Functions

func ConnDebug

func ConnDebug(cfg conf.Config) (string, error)

func Connect

func Connect(cfg conf.Config) (*sql.DB, error)

Connect to and open the database. This must be closed after use.

Types

type Connection

type Connection struct {
	Host     string // Host is the host name of the server.
	Port     uint   // Port is the port number the server is listening on.
	Database string // Database is the database name.
	User     string // User is the database user used to connect to the database.
	Pass     string // Pass is the password for the database user.
	// NoSSLMode connects to the database using an insecure,
	// plain text connecction using the sslmode=disable param.
	NoSSLMode bool
	Timeout   time.Duration // Timeout context in seconds.
}

Connection details of the MySQL database connection.

func (*Connection) Check

func (c *Connection) Check() error

func (Connection) MaskPass

func (c Connection) MaskPass(err error) error

MaskPass returns a MySQL database connection error with the user password removed.

func (Connection) Open

func (c Connection) Open() (*sql.DB, error)

Open opens a MySQL database connection.

func (Connection) Ping

func (c Connection) Ping(db *sql.DB) error

func (Connection) String

func (c Connection) String() string

String returns a MySQL database connection.

type Version

type Version string // Version of the MySQL in use.

func (*Version) Query

func (v *Version) Query(cfg conf.Config) error

Jump to

Keyboard shortcuts

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