sqlhandler

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMapSqlHandler

func NewMapSqlHandler(log logger.Logger, sqlconfigs map[string]config.SQL) map[string]database.SqlHandler

func NewSqlHandler

func NewSqlHandler(log logger.Logger, config Config) database.SqlHandler

Types

type Config

type Config interface {
	GetHost() string
	GetDatabase() string
	GetUser() string
	GetPassword() string
}

type SqlHandler

type SqlHandler struct {
	DB *sql.DB
	// contains filtered or unexported fields
}

SqlHandler has a connection with DB

func (*SqlHandler) Close

func (handler *SqlHandler) Close() error

func (*SqlHandler) Exec

func (handler *SqlHandler) Exec(statement string, args ...interface{}) (database.Result, error)

Exec executes the SQL that manipulates the data of the table

func (*SqlHandler) MultiExec

func (handler *SqlHandler) MultiExec(multiStatements string) (err error)

Use it for database initialization only

func (*SqlHandler) Query

func (handler *SqlHandler) Query(statement string, args ...interface{}) (database.Row, error)

Query gets data from the database

func (*SqlHandler) Transaction

func (handler *SqlHandler) Transaction(f func() (interface{}, error)) (interface{}, error)

Transaction ...

type SqlResult

type SqlResult struct {
	Result sql.Result
}

SqlResult ...

func (*SqlResult) LastInsertId

func (r *SqlResult) LastInsertId() (int64, error)

LastInsertId ...

func (*SqlResult) RowsAffected

func (r *SqlResult) RowsAffected() (int64, error)

RowsAffected ...

type SqlRow

type SqlRow struct {
	Rows *sql.Rows
}

SqlRow ...

func (*SqlRow) Close

func (r *SqlRow) Close() error

Close ...

func (*SqlRow) Next

func (r *SqlRow) Next() bool

Next ...

func (*SqlRow) Scan

func (r *SqlRow) Scan(dest ...interface{}) error

Scan ...

Jump to

Keyboard shortcuts

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