database

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	//CONNECTION_STRING user:password@tcp(host:port)/databaseName
	CONNECTION_STRING = "%s:%s@tcp(%s:%d)/%s"
)

Variables

This section is empty.

Functions

func Connect

func Connect(dbType DatabaseType, connStr string) *sql.DB

func CustomConnect

func CustomConnect(dbType string, connStr string) *sql.DB

func DBBoolean

func DBBoolean(b bool) []uint8

func Delete added in v0.9.5

func Delete(db *sql.DB, sql string, args ...any) (int64, error)

func Insert added in v0.9.5

func Insert(db *sql.DB, sql string, args ...any) (int64, error)

func PrepareExec added in v0.9.5

func PrepareExec(db *sql.DB, name, sql string, args ...any) (int64, error)

func PrepareQuery added in v0.9.5

func PrepareQuery(db *sql.DB, name, sql string, args ...any) ([]map[string]string, error)

func PrepareQueryRow added in v0.9.5

func PrepareQueryRow(db *sql.DB, name, sql string, args ...any) (map[string]string, error)

func PrepareQueryScalar added in v0.9.5

func PrepareQueryScalar(db *sql.DB, name, sql string, args ...any) (string, error)

func PrepareSql added in v0.9.5

func PrepareSql(db *sql.DB, name, sql string) (*sql.Stmt, error)

func Query added in v0.9.5

func Query(db *sql.DB, sql string, args ...any) ([]map[string]string, error)

func QueryRow added in v0.9.5

func QueryRow(db *sql.DB, sql string, args ...any) (map[string]string, error)

func QueryScalar added in v0.9.5

func QueryScalar(db *sql.DB, sql string, key string, args ...any) (string, error)

func Update added in v0.9.5

func Update(db *sql.DB, sql string, args ...any) (int64, error)

Types

type DBValue

type DBValue struct {
	Value any
}

func (*DBValue) ToBoolean

func (v *DBValue) ToBoolean() bool

func (*DBValue) ToBytes

func (v *DBValue) ToBytes() []byte

func (*DBValue) ToDouble

func (v *DBValue) ToDouble() float64

func (*DBValue) ToFloat

func (v *DBValue) ToFloat() float32

func (*DBValue) ToInt

func (v *DBValue) ToInt() int

func (*DBValue) ToInt64

func (v *DBValue) ToInt64() int64

func (*DBValue) ToString

func (v *DBValue) ToString() string

func (*DBValue) ToTime

func (v *DBValue) ToTime() time.Time

type DatabaseType

type DatabaseType int
const (
	MySQL      DatabaseType = iota // import _ "github.com/go-sql-driver/mysql"
	Oracle                         // import _ "github.com/mattn/go-oci8"
	SqlServer                      // import _ "github.com/denisenkom/go-mssqldb"
	PostgreSql                     // import _ "github.com/lib/pq"
	Sqlite3                        // import _ "github.com/mattn/go-sqlite3"
)

type Rows

type Rows struct {
	*sql.Rows
}

func (*Rows) GetByIndex

func (r *Rows) GetByIndex(index int) *DBValue

func (*Rows) GetByIndexDef

func (r *Rows) GetByIndexDef(index int, def any) *DBValue

func (*Rows) GetByName

func (r *Rows) GetByName(fieldName string) *DBValue

func (*Rows) GetByNameDef

func (r *Rows) GetByNameDef(fieldName string, def any) *DBValue

Jump to

Keyboard shortcuts

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