fakedb

package module
v0.0.0-...-1a6c3a6 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

README

go-fakedb

fake db driver for go sql/driver for benchmark purpose

Usage

db, err := sql.Open("fakedb", "example.csv")
if err != nil {
    t.Fatal(err)
}
defer db.Close()
rows, err := db.Query("select id, name from foo")
if err != nil {
    t.Fatal(err)
}
defer rows.Close()
var id string
var name string
rows.Next()
rows.Scan(&id, &name)
    

Test data

if query contains "count" it returns count, otherwise it returns contents in csv file specified in dsn. Note that the first line must be a header. see example

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
}

func (*Conn) Begin

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

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Prepare

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

type CountRows

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

func (*CountRows) Close

func (r *CountRows) Close() error

func (*CountRows) Columns

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

func (*CountRows) Next

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

type DataRows

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

func (*DataRows) Close

func (r *DataRows) Close() error

func (*DataRows) Columns

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

func (*DataRows) Next

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

type Driver

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

func (*Driver) Open

func (d *Driver) Open(fileName string) (driver.Conn, error)

type Result

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

func (*Result) LastInsertId

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

func (*Result) RowsAffected

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

type Stmt

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

func (*Stmt) Close

func (s *Stmt) Close() error

func (*Stmt) Exec

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

func (*Stmt) NumInput

func (s *Stmt) NumInput() int

func (*Stmt) Query

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

type Tx

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

func (*Tx) Commit

func (tx *Tx) Commit() error

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Jump to

Keyboard shortcuts

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