Documentation ¶
Index ¶
- Constants
- type HaSqliteConn
- func (c *HaSqliteConn) Begin() (driver.Tx, error)deprecated
- func (c *HaSqliteConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
- func (c *HaSqliteConn) Close() error
- func (c *HaSqliteConn) Exec(query string, args []driver.Value) (driver.Result, error)
- func (c *HaSqliteConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (c *HaSqliteConn) ExecContextWithDbName(ctx context.Context, dbName string, query string, args []driver.NamedValue) (driver.Result, error)
- func (c *HaSqliteConn) Ping(ctx context.Context) error
- func (c *HaSqliteConn) Prepare(query string) (driver.Stmt, error)
- func (c *HaSqliteConn) PrepareContext(ctx context.Context, query string) (driver.StmtExecContext, error)
- func (c *HaSqliteConn) Query(query string, args []driver.Value) (driver.Rows, error)
- func (c *HaSqliteConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- func (c *HaSqliteConn) QueryContextWithDbName(ctx context.Context, dbName string, query string, args []driver.NamedValue) (driver.Rows, error)
- type HaSqliteConnector
- type HaSqliteDriver
- type HaSqliteStmt
- func (s *HaSqliteStmt) Close() error
- func (s *HaSqliteStmt) Exec(args []driver.Value) (driver.Result, error)deprecated
- func (s *HaSqliteStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
- func (s *HaSqliteStmt) NumInput() int
- func (s *HaSqliteStmt) Query(args []driver.Value) (driver.Rows, error)deprecated
- func (s *HaSqliteStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)
- type HaSqliteTx
Constants ¶
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 ¶
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) 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) 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 ¶
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 ¶
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 ¶
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 ¶
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) 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) 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 ¶
func NewHaSqliteTx ¶
func NewHaSqliteTx(conn *HaSqliteConn) (*HaSqliteTx, error)
func (*HaSqliteTx) Commit ¶
func (tx *HaSqliteTx) Commit() error
func (*HaSqliteTx) Rollback ¶
func (tx *HaSqliteTx) Rollback() error