db

package
v0.0.36-pre6 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2025 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

View Source
const (
	DriverMySQL      = Driver("mysql")
	DriverPostgresQL = Driver("postgres")
	DriverSQLite     = Driver("sqlite3")
)

Driver is type of database driver. Current supported driver are:

- `DriverMySQL`

- `DriverPostgresQL`

- `DriverSQLite`

This type is string, so you can use string literal to represent driver name. For example: `db.Driver("mysql")` is equal with `db.DriverMySQL`.

This type is useful for `db.Config` struct.

Variables

This section is empty.

Functions

func Init

func Init(cfg Config) (*sql.DB, error)

Init connect to database and return *sql.DB.

This function will be switch to mysql, postgresql, sqlite driver.

If driver not found, this function will return error with code `github.com/irdaislakhuafa/go-sdk/codes.CodeNotImplemented`.

Types

type Config

type Config struct {
	Driver   Driver
	User     string
	Password string
	Port     string
	Host     string
	Name     string
	Options  Options
}

type Driver

type Driver string

type Options

type Options struct {
	SSLMode   string
	ParseTime bool
	InMemory  bool // only for sqlite
}

Jump to

Keyboard shortcuts

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