mariadb

package
v0.0.140 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package mariadb provides constructor to connect to mariadb with standard sql

Index

Constants

View Source
const (
	ProtocolTCP        = "tcp"
	ProtocolUNIXSocket = "unix"
)

Protocol = UNIXSocket, Address = "/tmp/mysql.sock" Protocol = TCP, Address = "localhost:5555"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Protocol string
	Address  string
	Schema   string
	User     string
	Password string
	Charset  string
}

Config describe connection params to database

func (*Config) GetDSN

func (cfg *Config) GetDSN() string

GetDSN return DSN string for db connection params

type Conn

type Conn struct {
	*sql.DB
	*types.DBLog
}

Conn database connection and log

type DBQuery

type DBQuery interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	Begin() (*sql.Tx, error)
	BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
	Close() error
	types.SQLLogger
}

DBQuery describe interface

func New

func New(cfg *Config, log types.SQLLoggerFunc) (DBQuery, error)

New create new database connection

Jump to

Keyboard shortcuts

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