connection

package
v0.0.0-...-dfd9850 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

Connection define connection struct

func New

func New(dsn string, opt *Option) (*Connection, error)

New create Connection instance from dsn

func (*Connection) Begin

func (c *Connection) Begin() error

Begin a txn

func (*Connection) CloseDB

func (c *Connection) CloseDB() error

CloseDB close connection

func (*Connection) Commit

func (c *Connection) Commit() error

Commit a txn

func (*Connection) Delete

func (c *Connection) Delete(stmt string) (int64, error)

Delete run delete statement and return error

func (*Connection) Exec

func (c *Connection) Exec(stmt string) error

Exec do any exec actions

func (*Connection) ExecDDL

func (c *Connection) ExecDDL(query string, args ...interface{}) error

ExecDDL do DDL actions

func (*Connection) FetchColumns

func (c *Connection) FetchColumns(db, table string) ([][2]string, error)

FetchColumns get columns for given table

func (*Connection) FetchDatabases

func (c *Connection) FetchDatabases() ([]string, error)

FetchDatabases database list

func (*Connection) FetchIndexes

func (c *Connection) FetchIndexes(db, table string) ([]string, error)

FetchIndexes get indexes for given table

func (*Connection) FetchSchema

func (c *Connection) FetchSchema(db string) ([][5]string, error)

FetchSchema get schema of given database from database

func (*Connection) FetchTables

func (c *Connection) FetchTables(db string) ([]string, error)

FetchTables table list

func (*Connection) GeneralLog

func (c *Connection) GeneralLog(v int) error

GeneralLog turn on or turn off general_log in TiDB

func (*Connection) GetBeginTime

func (c *Connection) GetBeginTime() time.Time

GetBeginTime get the begin time of a transaction if not in transaction, return 0

func (*Connection) IfTxn

func (c *Connection) IfTxn() bool

IfTxn show if in a transaction

func (*Connection) Insert

func (c *Connection) Insert(stmt string) (int64, error)

Insert run insert statement and return error

func (*Connection) Prepare

func (c *Connection) Prepare() error

Prepare connection

func (*Connection) ReConnect

func (c *Connection) ReConnect() error

ReConnect rebuild connection

func (*Connection) Rollback

func (c *Connection) Rollback() error

Rollback a txn

func (*Connection) Select

func (c *Connection) Select(stmt string, args ...interface{}) ([][]*QueryItem, error)

Select run select statement and return query result

func (*Connection) SetTiFlashEngine

func (c *Connection) SetTiFlashEngine() error

SetTiFlashEngine sets the isolation to TiFlash in TiDB

func (*Connection) ShowDatabases

func (c *Connection) ShowDatabases() ([]string, error)

ShowDatabases list databases

func (*Connection) Update

func (c *Connection) Update(stmt string) (int64, error)

Update run update statement and return error

type Option

type Option struct {
	Name          string
	Log           string
	Mute          bool
	GeneralLog    bool
	EnableTiFlash bool
}

Option struct

type QueryItem

type QueryItem struct {
	Null      bool
	ValType   *sql.ColumnType
	ValString string
}

QueryItem define query result

func (*QueryItem) MustSame

func (q *QueryItem) MustSame(q1 *QueryItem) error

MustSame compare tow QueryItem and return error if not same

Jump to

Keyboard shortcuts

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