database

package
v0.0.0-...-12ab560 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

database provide common database methods

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	*sql.DB
}

func NewDatabase

func NewDatabase() (*Database, error)

NewDatabase returns a Database

Example
os.Setenv("DOCKER_NAME", "utest01")
_, err := NewDatabase()
fmt.Println(err)

os.Setenv("DOCKER_NAME", "")
_, err = NewDatabase()
fmt.Println(err)
Output:

<nil>
<nil>

func (*Database) Exec

func (db *Database) Exec(statement string, parameters ...interface{}) (res sql.Result, err error)

Exec runs database dml insert/update/delete, or ddl create/alter

func (*Database) Query

func (db *Database) Query(statement string, parameters ...interface{}) (res *sql.Rows, err error)

Query runs a database queriy

Jump to

Keyboard shortcuts

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