ramsql

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

Conn implements sql/driver Conn interface

All Conn implementations should implement the following interaces: Pinger, SessionResetter, and Validator.

If a Conn does not implement QueryerContext, the sql package's DB.Query will fall back to Queryer; if the Conn does not implement Queryer either, DB.Query will first prepare a query, execute the statement, and then close the statement.

If named parameters or context are supported, the driver's Conn should implement: ExecerContext, QueryerContext, ConnPrepareContext, and ConnBeginTx.

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

https://pkg.go.dev/database/sql/driver#Conn

https://pkg.go.dev/database/sql/driver#Pinger https://pkg.go.dev/database/sql/driver#SessionResetter https://pkg.go.dev/database/sql/driver#Validator https://pkg.go.dev/database/sql/driver#QueryerContext https://pkg.go.dev/database/sql/driver#ExecerContext https://pkg.go.dev/database/sql/driver#ConnPrepareContext https://pkg.go.dev/database/sql/driver#ConnBeginTx

func (*Conn) Begin deprecated

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

Begin starts and returns a new transaction.

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

Implemented for Conn interface

func (*Conn) BeginTx

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

BeginTx starts and returns a new transaction.

Implemented for ConnBeginTx interface

func (*Conn) Close

func (c *Conn) 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.

Implemented for Conn interface

func (*Conn) Commit

func (c *Conn) Commit() error

func (*Conn) ExecContext

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

ExecContext is the sql package prefered way to run Exec

Implemented for ExecerContext interface

func (*Conn) IsValid

func (c *Conn) IsValid() bool

IsValid is called prior to placing the connection into the connection pool. The connection will be discarded if false is returned.

Implemented for Validator interface

func (*Conn) Ping

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

Ping

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

Implemented for Pinger interface

func (*Conn) Prepare

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

Prepare returns a prepared statement, bound to this connection.

Implemented for Conn interface

func (*Conn) QueryContext

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

QueryContext is the sql package prefered way to run QUERY.

Implemented for QueryerContext interface

func (*Conn) ResetSession

func (c *Conn) ResetSession(ctx context.Context) error

ResetSession is called prior to executing a query on the connection if the connection has been used before. If the driver returns ErrBadConn the connection is discarded.

Implemented for SessionResetter interface

func (*Conn) Rollback

func (c *Conn) Rollback() error

type Driver

type Driver struct {
	// Mutex protect the map of engine
	sync.Mutex
	// contains filtered or unexported fields
}

Driver is the driver entrypoint

Drivers should implement Connector and DriverContext interaces.

https://pkg.go.dev/database/sql/driver#Connector https://pkg.go.dev/database/sql/driver#DriverContext

func NewDriver

func NewDriver() *Driver

NewDriver creates a driver object

func (*Driver) Open

func (rs *Driver) Open(dsn string) (conn driver.Conn, err error)

Open return an active connection so RamSQL engine If there is no connection in pool, start a new engine. After first instantiation of the engine,

type Result

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

Result is the type returned by sql/driver after an Exec statement.

func (*Result) LastInsertId

func (r *Result) LastInsertId() (int64, error)

LastInsertId returns the database's auto-generated ID after, for example, an INSERT into a table with primary key.

func (*Result) RowsAffected

func (r *Result) RowsAffected() (int64, error)

RowsAffected returns the number of rows affected by the query.

type Rows

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

Rows implements the sql/driver Rows interface

func (*Rows) Close

func (r *Rows) Close() error

Close closes the rows iterator.

func (*Rows) Columns

func (r *Rows) Columns() []string

Columns returns the names of the columns. The number of columns of the result is inferred from the length of the slice. If a particular column name isn't known, an empty string should be returned for that entry.

func (*Rows) Next

func (r *Rows) Next(dest []driver.Value) (err error)

Next is called to populate the next row of data into the provided slice. The provided slice will be the same size as the Columns() are wide.

The dest slice may be populated only with a driver Value type, but excluding string. All string values must be converted to []byte.

Next should return io.EOF when there are no more rows.

type Stmt

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

Stmt implements the Statement interface of sql/driver

func (*Stmt) Close

func (s *Stmt) 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.

func (*Stmt) Exec

func (s *Stmt) Exec(args []driver.Value) (r driver.Result, err error)

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

func (*Stmt) NumInput

func (s *Stmt) 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 (*Stmt) Query

func (s *Stmt) Query(args []driver.Value) (r driver.Rows, err error)

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

Jump to

Keyboard shortcuts

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