mysqldb

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2025 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InteractiveConfig

func InteractiveConfig(defaults dictx.Dict) (dictx.Dict, error)

InteractiveConfig gets the database configuration interactively from console. it takes default options and return new input options.

The parsed default options are:

  • database: (string) the database name - REQUIRED
  • address: (string) the database server address - REQUIRED
  • username: (string) the database access username (if any)
  • password: (string) the database access password (if any)
  • connect_args: (string) holds connection params

func InteractiveSetup

func InteractiveSetup(log *logging.Logger, opts dictx.Dict) error

InteractiveSetup performs an interactive console based database setup. it takes database options and makes config validation.

The parsed options are:

  • database: (string) the database name - REQUIRED
  • address: (string) the database server address - REQUIRED
  • username: (string) the database access username (if any)
  • password: (string) the database access password (if any)
  • connect_args: (string) holds connection params

Types

type Config

type Config struct {
	// Database name
	Database string
	// Database server address
	Address string
	// Database access username
	Username string
	// Database access password
	Password string
	// ConnectArgs holds connection params
	ConnectArgs string
}

Config represents the database configuration params.

https://github.com/go-sql-driver/mysql?tab=readme-ov-file#dsn-data-source-name

func NewConfig

func NewConfig(opts dictx.Dict) (*Config, error)

NewConfig creates configuration object from options dict. it checks and returns error if not all options have valid values.

The parsed options are:

  • database: (string) the database name - REQUIRED
  • address: (string) the database server address - REQUIRED
  • username: (string) the database access username (if any)
  • password: (string) the database access password (if any)
  • connect_args: (string) holds connection params

func (*Config) DSN

func (cfg *Config) DSN() string

DSN returns the driver-specific data source name.

format: [username[:password]@]address/dbname[?param1=value1&...&paramN=valueN]

type Engine

type Engine struct {
	// Log is the logger instance for database logging.
	Log *logging.Logger
	// contains filtered or unexported fields
}

Engine represents the backend engine structure.

func NewEngine

func NewEngine(log *logging.Logger, opts dictx.Dict) (*Engine, error)

NewEngine creates new engine handler for the backend.

func (*Engine) Backend

func (e *Engine) Backend() string

Backend returns the engine backend type.

func (*Engine) CanRetryErr

func (e *Engine) CanRetryErr(err error) bool

CanRetryErr checks weather an operation error type can be retried.

func (*Engine) Close

func (e *Engine) Close(_ *sql.DB) error

Close shutsdown the backend driver handler and free resources.

func (*Engine) Release

func (e *Engine) Release(_ *sql.DB) error

Release frees the backend driver resources between sessions.

func (*Engine) SqlDB

func (e *Engine) SqlDB() (*sql.DB, error)

SqlDB create or return existing backend driver handler.

func (*Engine) SqlGenerator

func (e *Engine) SqlGenerator() sqldb.SqlGenerator

SqlGenerator returns the engine SQL statment generator.

type SqlGenerator

type SqlGenerator struct {
	sqldb.StdSqlGenerator
}

SqlGenerator represents mysql SQL statment generator.

func (*SqlGenerator) Schema

func (g *SqlGenerator) Schema(tablename string, meta *sqldb.TableMeta) []string

Schema generates table schema statments from metainfo

Jump to

Keyboard shortcuts

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