mydb

package
v0.0.0-...-6af97ad Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PG    = "postgres"
	MYSQL = "mysql"
)

Variables

This section is empty.

Functions

func NewMysqlUrl

func NewMysqlUrl(c DbConfig) string

func NewPqUrl

func NewPqUrl(c DbConfig) string

Types

type DbConfig

type DbConfig struct {
	Name    string
	Host    string
	User    string
	Pass    string
	Port    string
	Sslmode string // sslmode=verify-full require
}

type MyDb

type MyDb struct {
	Config MyDbConfig
	Client *xorm.Engine
}

func NewDb

func NewDb(config MyDbConfig) (*MyDb, error)

func (*MyDb) CreateTables

func (db *MyDb) CreateTables(beanOrTableName interface{}) error

func (*MyDb) Delete

func (db *MyDb) Delete(bean interface{}) (int64, error)

func (*MyDb) DropTables

func (db *MyDb) DropTables(beans ...interface{}) error

func (*MyDb) Exec

func (db *MyDb) Exec(sql string, args ...interface{}) (sql.Result, error)

sql = "update `userinfo` set username=? where id=?" res, err := engine.Exec(sql, "xiaolun", 1)

func (*MyDb) Insert

func (db *MyDb) Insert(beans ...interface{}) (int64, error)

func (*MyDb) InsertOne

func (db *MyDb) InsertOne(beans interface{}) (int64, error)

func (*MyDb) IsTableExist

func (db *MyDb) IsTableExist(beanOrTableName interface{}) (bool, error)

func (*MyDb) Ping

func (db *MyDb) Ping() error

func (*MyDb) Query

func (db *MyDb) Query(sql string, paramStr ...interface{}) (resultsSlice []map[string][]byte, err error)

func (*MyDb) Update

func (db *MyDb) Update(bean interface{}, condiBean ...interface{}) (int64, error)

type MyDbConfig

type MyDbConfig struct {
	DriverName string
	DbConfig
	MaxIdleConns int
	MaxOpenConns int
	DebugToFile  bool
	Debug        bool
}

Jump to

Keyboard shortcuts

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