driver

package
v1.4.17 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect added in v1.4.17

func Connect(driver string, datasource string, opts ...ConnectOptionFunc) (*sql.DB, error)

Connect connects to the database.

func Drivers added in v1.4.17

func Drivers() []string

Drivers returns a sorted list of the names of the registered drivers.

func Register

func Register(name string, driver Driver)

Register registers a driver. The name is used to get a driver.

Types

type ConnectOptionFunc added in v1.4.17

type ConnectOptionFunc func(*connectOption)

ConnectOptionFunc is a function to set the connection option.

func ConnectWithMaxConnLifetime added in v1.4.17

func ConnectWithMaxConnLifetime(d time.Duration) ConnectOptionFunc

ConnectWithMaxConnLifetime sets the maximum lifetime of a connection.

func ConnectWithMaxIdleConnLifetime added in v1.4.17

func ConnectWithMaxIdleConnLifetime(d time.Duration) ConnectOptionFunc

ConnectWithMaxIdleConnLifetime sets the maximum lifetime of an idle connection.

func ConnectWithMaxIdleConnNum added in v1.4.17

func ConnectWithMaxIdleConnNum(num int) ConnectOptionFunc

ConnectWithMaxIdleConnNum sets the maximum number of idle connections.

func ConnectWithMaxOpenConnNum added in v1.4.17

func ConnectWithMaxOpenConnNum(num int) ConnectOptionFunc

ConnectWithMaxOpenConnNum sets the maximum number of open connections.

type Driver

type Driver interface {
	// Translator returns a translator of SQL.
	Translator() Translator
}

Driver is a driver of database.

func Get

func Get(name string) (Driver, error)

Get returns a driver of the name. If the name is not registered, it returns an error.

type MySQLDriver

type MySQLDriver struct{}

MySQLDriver is a driver of MySQL.

func (MySQLDriver) String

func (d MySQLDriver) String() string

func (MySQLDriver) Translator added in v1.4.17

func (d MySQLDriver) Translator() Translator

Translator returns a translator of SQL.

type OracleDriver

type OracleDriver struct{}

OracleDriver is a driver of Oracle.

func (OracleDriver) String

func (o OracleDriver) String() string

func (OracleDriver) Translator added in v1.3.7

func (o OracleDriver) Translator() Translator

Translator is a function to translate a matched string.

type PostgresDriver

type PostgresDriver struct{}

PostgresDriver is a driver of PostgreSQL.

func (PostgresDriver) String

func (d PostgresDriver) String() string

func (PostgresDriver) Translator added in v1.3.7

func (d PostgresDriver) Translator() Translator

Translator is a function to translate a matched string.

type SQLiteDriver

type SQLiteDriver struct{}

SQLiteDriver is a driver of SQLite.

func (SQLiteDriver) String

func (d SQLiteDriver) String() string

func (SQLiteDriver) Translator added in v1.4.17

func (d SQLiteDriver) Translator() Translator

Translator returns a translator of SQL.

type TranslateFunc

type TranslateFunc func(matched string) string

TranslateFunc is a function to translate the matched string.

func (TranslateFunc) Translate

func (f TranslateFunc) Translate(matched string) string

Translate implements the Translator interface.

type Translator

type Translator interface {
	Translate(matched string) string
}

Translator is an interface for translating the matched string.

Jump to

Keyboard shortcuts

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