driver

package
v0.0.0-...-4b30ddc Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const MaxTupleParams = 255

Variables

This section is empty.

Functions

This section is empty.

Types

type HaSqliteConn

type HaSqliteConn struct {
	driver.Conn
	// Address 数据库链接地址
	Address string

	Client proto.DBClient
	// contains filtered or unexported fields
}

func NewHaSqliteConn

func NewHaSqliteConn(ctx context.Context, dsn string) (*HaSqliteConn, error)

func (*HaSqliteConn) Begin deprecated

func (c *HaSqliteConn) Begin() (driver.Tx, error)

Begin starts and returns a new transaction.

Deprecated: Drivers should implement ConnBeginTx instead (or additionally).

func (*HaSqliteConn) BeginTx

func (c *HaSqliteConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)

BeginTx starts and returns a new transaction. If the context is canceled by the user the sql package will call Tx.Rollback before discarding and closing the connection.

This must check opts.Isolation to determine if there is a set isolation level. If the driver does not support a non-default level and one is set or if there is a non-default isolation level that is not supported, an error must be returned.

This must also check opts.ReadOnly to determine if the read-only value is true to either set the read-only transaction property if supported or return an error if it is not supported.

func (*HaSqliteConn) Close

func (c *HaSqliteConn) Close() error

Close invalidates and potentially stops any current prepared statements and transactions, marking this connection as no longer in use.

Because the sql package maintains a free pool of connections and only calls Close when there's a surplus of idle connections, it shouldn't be necessary for drivers to do their own connection caching.

Drivers must ensure all network calls made by Close do not block indefinitely (e.g. apply a timeout).

func (*HaSqliteConn) Exec

func (c *HaSqliteConn) Exec(query string, args []driver.Value) (driver.Result, error)

Exec is an optional interface that may be implemented by a Conn.

func (*HaSqliteConn) ExecContext

func (c *HaSqliteConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)

ExecContext is an optional interface that may be implemented by a Conn.

func (*HaSqliteConn) ExecContextWithDbName

func (c *HaSqliteConn) ExecContextWithDbName(ctx context.Context, dbName string, query string, args []driver.NamedValue) (driver.Result, error)

ExecContextWithDbName 通过外部的数据库名称执行sql语句

func (*HaSqliteConn) Ping

func (c *HaSqliteConn) Ping(ctx context.Context) error

Ping is an optional interface that may be implemented by a Conn.

If a Conn does not implement Pinger, the sql package's DB.Ping and DB.PingContext will check if there is at least one Conn available.

If Conn.Ping returns ErrBadConn, DB.Ping and DB.PingContext will remove the Conn from pool.}

func (*HaSqliteConn) Prepare

func (c *HaSqliteConn) Prepare(query string) (driver.Stmt, error)

Prepare returns a prepared statement, bound to this connection.

func (*HaSqliteConn) PrepareContext

func (c *HaSqliteConn) PrepareContext(ctx context.Context, query string) (driver.StmtExecContext, error)

PrepareContext returns a prepared statement, bound to this connection. context is for the preparation of the statement, it must not store the context within the statement itself.

func (*HaSqliteConn) Query

func (c *HaSqliteConn) Query(query string, args []driver.Value) (driver.Rows, error)

Query is an optional interface that may be implemented by a Conn.

func (*HaSqliteConn) QueryContext

func (c *HaSqliteConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)

QueryContext is an optional interface that may be implemented by a Conn.

func (*HaSqliteConn) QueryContextWithDbName

func (c *HaSqliteConn) QueryContextWithDbName(ctx context.Context, dbName string, query string, args []driver.NamedValue) (driver.Rows, error)

QueryContextWithDbName 通过外部的数据库名称执行查询sql语句

type HaSqliteConnector

type HaSqliteConnector struct {
	driver.Connector
	// contains filtered or unexported fields
}

HaSqliteConnector A Connector represents a driver in a fixed configuration and can create any number of equivalent Conns for use by multiple goroutines.

A Connector can be passed to sql.OpenDB, to allow drivers to implement their own sql.DB constructors, or returned by DriverContext's OpenConnector method, to allow drivers access to context and to avoid repeated parsing of driver configuration.

If a Connector implements io.Closer, the sql package's DB.Close method will call Close and return error (if any).

func (*HaSqliteConnector) Connect

func (c *HaSqliteConnector) Connect(ctx context.Context) (driver.Conn, error)

Connect returns a connection to the database. Connect may return a cached connection (one previously closed), but doing so is unnecessary; the sql package maintains a pool of idle connections for efficient re-use.

The provided context.Context is for dialing purposes only (see net.DialContext) and should not be stored or used for other purposes. A default timeout should still be used when dialing as a connection pool may call Connect asynchronously to any query.

The returned connection is only used by one goroutine at a time.

func (*HaSqliteConnector) Driver

func (c *HaSqliteConnector) Driver() driver.Driver

Driver returns the underlying Driver of the Connector, mainly to maintain compatibility with the Driver method on sql.DB.

type HaSqliteDriver

type HaSqliteDriver struct {
	driver.Driver
	DriverName string
}

func NewHaSqliteDriver

func NewHaSqliteDriver() *HaSqliteDriver

func (*HaSqliteDriver) Open

func (d *HaSqliteDriver) Open(name string) (driver.Conn, error)

Open 支持 multi:/// 或单个链接地址

func (*HaSqliteDriver) OpenConnector

func (d *HaSqliteDriver) OpenConnector(name string) (driver.Connector, error)

OpenConnector must parse the name in the same format that Driver.Open parses the name parameter.

type HaSqliteStmt

type HaSqliteStmt struct {
	driver.Stmt
	// contains filtered or unexported fields
}

func NewHaSqliteStmt

func NewHaSqliteStmt(ctx context.Context, client proto.DBClient, dbId int64, txToken string, query string) (*HaSqliteStmt, error)

NewHaSqliteStmt TODO 实现真实的预编译动作

func (*HaSqliteStmt) Close

func (s *HaSqliteStmt) Close() error

Close closes the statement.

As of Go 1.1, a Stmt will not be closed if it's in use by any queries.

Drivers must ensure all network calls made by Close do not block indefinitely (e.g. apply a timeout).

func (*HaSqliteStmt) Exec deprecated

func (s *HaSqliteStmt) Exec(args []driver.Value) (driver.Result, error)

Exec executes a query that doesn't return rows, such as an INSERT or UPDATE.

Deprecated: Drivers should implement StmtExecContext instead (or additionally).

func (*HaSqliteStmt) ExecContext

func (s *HaSqliteStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)

ExecContext is an optional interface that may be implemented by a Conn.

func (*HaSqliteStmt) NumInput

func (s *HaSqliteStmt) NumInput() int

NumInput returns the number of placeholder parameters.

If NumInput returns >= 0, the sql package will sanity check argument counts from callers and return errors to the caller before the statement's Exec or Query methods are called.

NumInput may also return -1, if the driver doesn't know its number of placeholders. In that case, the sql package will not sanity check Exec or Query argument counts.

func (*HaSqliteStmt) Query deprecated

func (s *HaSqliteStmt) Query(args []driver.Value) (driver.Rows, error)

Query executes a query that may return rows, such as a SELECT.

Deprecated: Drivers should implement StmtQueryContext instead (or additionally).

func (*HaSqliteStmt) QueryContext

func (s *HaSqliteStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)

QueryContext is an optional interface that may be implemented by a Conn.

type HaSqliteTx

type HaSqliteTx struct {
	driver.Tx
	// contains filtered or unexported fields
}

func NewHaSqliteTx

func NewHaSqliteTx(conn *HaSqliteConn) (*HaSqliteTx, error)

func (*HaSqliteTx) Commit

func (tx *HaSqliteTx) Commit() error

func (*HaSqliteTx) Rollback

func (tx *HaSqliteTx) Rollback() error

Jump to

Keyboard shortcuts

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