sqlite3

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 20 Imported by: 41

README

Go bindings to SQLite using Wazero

Go Reference Go Report Go Coverage

⚠️ CAUTION ⚠️

This is a WIP.
DO NOT USE with data you care about.

Roadmap:

  • build SQLite using zig cc --target=wasm32-wasi
  • :memory: databases
  • port test_demovfs.c to Go
    • branch wasi uses test_demovfs.c directly
  • design a simple, nice API, enough for simple use cases
  • provide a simple database/sql driver
  • file locking, compatible with SQLite on Windows/Unix
  • shared memory, compatible with SQLite on Windows/Unix
    • needed for improved WAL mode

Documentation

Overview

Package sqlite3 wraps the C SQLite API.

Example
package main

import (
	"fmt"
	"log"

	"github.com/ncruces/go-sqlite3"
	_ "github.com/ncruces/go-sqlite3/embed"
)

const memory = ":memory:"

func main() {
	db, err := sqlite3.Open(memory)
	if err != nil {
		log.Fatal(err)
	}

	err = db.Exec(`CREATE TABLE IF NOT EXISTS users (id INT, name VARCHAR(10))`)
	if err != nil {
		log.Fatal(err)
	}

	err = db.Exec(`INSERT INTO users(id, name) VALUES(0, 'go'), (1, 'zig'), (2, 'whatever')`)
	if err != nil {
		log.Fatal(err)
	}

	stmt, _, err := db.Prepare(`SELECT id, name FROM users`)
	if err != nil {
		log.Fatal(err)
	}

	for stmt.Step() {
		fmt.Println(stmt.ColumnInt(0), stmt.ColumnText(1))
	}
	if err := stmt.Err(); err != nil {
		log.Fatal(err)
	}

	err = stmt.Close()
	if err != nil {
		log.Fatal(err)
	}

	err = db.Close()
	if err != nil {
		log.Fatal(err)
	}

}
Output:

0 go
1 zig
2 whatever

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	Binary []byte // Binary to load.
	Path   string // Path to load the binary from.
)

Configure SQLite.

Functions

This section is empty.

Types

type Conn

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

Conn is a database connection handle.

https://www.sqlite.org/c3ref/sqlite3.html

func Open

func Open(filename string) (conn *Conn, err error)

Open calls OpenFlags with OPEN_READWRITE and OPEN_CREATE.

func OpenFlags

func OpenFlags(filename string, flags OpenFlag) (conn *Conn, err error)

OpenFlags opens an SQLite database file as specified by the filename argument.

https://www.sqlite.org/c3ref/open.html

func (*Conn) Changes added in v0.2.0

func (c *Conn) Changes() uint64

Changes returns the number of rows modified, inserted or deleted by the most recently completed INSERT, UPDATE or DELETE statement on the database connection.

https://www.sqlite.org/c3ref/changes.html

func (*Conn) Close

func (c *Conn) Close() error

Close closes the database connection.

If the database connection is associated with unfinalized prepared statements, open blob handles, and/or unfinished backup objects, Close will leave the database connection open and return BUSY.

https://www.sqlite.org/c3ref/close.html

func (*Conn) Exec

func (c *Conn) Exec(sql string) error

Exec is a convenience function that allows an application to run multiple statements of SQL without having to use a lot of code.

https://www.sqlite.org/c3ref/exec.html

func (*Conn) LastInsertRowID added in v0.2.0

func (c *Conn) LastInsertRowID() uint64

LastInsertRowID returns the rowid of the most recent successful INSERT on the database connection.

https://www.sqlite.org/c3ref/last_insert_rowid.html

func (*Conn) Prepare

func (c *Conn) Prepare(sql string) (stmt *Stmt, tail string, err error)

Prepare calls Conn.PrepareFlags with no flags.

func (*Conn) PrepareFlags

func (c *Conn) PrepareFlags(sql string, flags PrepareFlag) (stmt *Stmt, tail string, err error)

PrepareFlags compiles the first SQL statement in sql; tail is left pointing to what remains uncompiled. If the input text contains no SQL (if the input is an empty string or a comment), both stmt and err will be nil.

https://www.sqlite.org/c3ref/prepare.html

func (*Conn) SetInterrupt added in v0.2.0

func (c *Conn) SetInterrupt(done <-chan struct{}) (old <-chan struct{})

SetInterrupt interrupts a long-running query when done is closed.

Subsequent uses of the connection will return INTERRUPT until done is reset by another call to SetInterrupt.

Typically, done is provided by context.Context.Done:

ctx, cancel := context.WithTimeout(context.TODO(), 100*time.Millisecond)
conn.SetInterrupt(ctx.Done())
defer cancel()

https://www.sqlite.org/c3ref/interrupt.html

type Datatype

type Datatype uint32

Datatype is a fundamental datatype of SQLite.

https://www.sqlite.org/c3ref/c_blob.html

const (
	INTEGER Datatype = 1
	FLOAT   Datatype = 2
	TEXT    Datatype = 3
	BLOB    Datatype = 4
	NULL    Datatype = 5
)

func (Datatype) String

func (t Datatype) String() string

type Error

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

Error wraps an SQLite Error Code.

https://www.sqlite.org/c3ref/errcode.html

func (*Error) Code

func (e *Error) Code() ErrorCode

Code returns the primary error code for this error.

https://www.sqlite.org/rescode.html

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) ExtendedCode

func (e *Error) ExtendedCode() ExtendedErrorCode

ExtendedCode returns the extended error code for this error.

https://www.sqlite.org/rescode.html

func (*Error) SQL

func (e *Error) SQL() string

SQL returns the SQL starting at the token that triggered a syntax error.

type ErrorCode

type ErrorCode uint8

ErrorCode is a result code that Error.Code might return.

https://www.sqlite.org/rescode.html

const (
	ERROR      ErrorCode = 1  /* Generic error */
	INTERNAL   ErrorCode = 2  /* Internal logic error in SQLite */
	PERM       ErrorCode = 3  /* Access permission denied */
	ABORT      ErrorCode = 4  /* Callback routine requested an abort */
	BUSY       ErrorCode = 5  /* The database file is locked */
	LOCKED     ErrorCode = 6  /* A table in the database is locked */
	NOMEM      ErrorCode = 7  /* A malloc() failed */
	READONLY   ErrorCode = 8  /* Attempt to write a readonly database */
	INTERRUPT  ErrorCode = 9  /* Operation terminated by sqlite3_interrupt() */
	IOERR      ErrorCode = 10 /* Some kind of disk I/O error occurred */
	CORRUPT    ErrorCode = 11 /* The database disk image is malformed */
	NOTFOUND   ErrorCode = 12 /* Unknown opcode in sqlite3_file_control() */
	FULL       ErrorCode = 13 /* Insertion failed because database is full */
	CANTOPEN   ErrorCode = 14 /* Unable to open the database file */
	PROTOCOL   ErrorCode = 15 /* Database lock protocol error */
	EMPTY      ErrorCode = 16 /* Internal use only */
	SCHEMA     ErrorCode = 17 /* The database schema changed */
	TOOBIG     ErrorCode = 18 /* String or BLOB exceeds size limit */
	CONSTRAINT ErrorCode = 19 /* Abort due to constraint violation */
	MISMATCH   ErrorCode = 20 /* Data type mismatch */
	MISUSE     ErrorCode = 21 /* Library used incorrectly */
	NOLFS      ErrorCode = 22 /* Uses OS features not supported on host */
	AUTH       ErrorCode = 23 /* Authorization denied */
	FORMAT     ErrorCode = 24 /* Not used */
	RANGE      ErrorCode = 25 /* 2nd parameter to sqlite3_bind out of range */
	NOTADB     ErrorCode = 26 /* File opened that is not a database file */
	NOTICE     ErrorCode = 27 /* Notifications from sqlite3_log() */
	WARNING    ErrorCode = 28 /* Warnings from sqlite3_log() */
)

type ExtendedErrorCode

type ExtendedErrorCode uint16

ExtendedErrorCode is a result code that Error.ExtendedCode might return.

https://www.sqlite.org/rescode.html

const (
	ERROR_MISSING_COLLSEQ   ExtendedErrorCode = xErrorCode(ERROR) | (1 << 8)
	ERROR_RETRY             ExtendedErrorCode = xErrorCode(ERROR) | (2 << 8)
	ERROR_SNAPSHOT          ExtendedErrorCode = xErrorCode(ERROR) | (3 << 8)
	IOERR_READ              ExtendedErrorCode = xErrorCode(IOERR) | (1 << 8)
	IOERR_SHORT_READ        ExtendedErrorCode = xErrorCode(IOERR) | (2 << 8)
	IOERR_WRITE             ExtendedErrorCode = xErrorCode(IOERR) | (3 << 8)
	IOERR_FSYNC             ExtendedErrorCode = xErrorCode(IOERR) | (4 << 8)
	IOERR_DIR_FSYNC         ExtendedErrorCode = xErrorCode(IOERR) | (5 << 8)
	IOERR_TRUNCATE          ExtendedErrorCode = xErrorCode(IOERR) | (6 << 8)
	IOERR_FSTAT             ExtendedErrorCode = xErrorCode(IOERR) | (7 << 8)
	IOERR_UNLOCK            ExtendedErrorCode = xErrorCode(IOERR) | (8 << 8)
	IOERR_RDLOCK            ExtendedErrorCode = xErrorCode(IOERR) | (9 << 8)
	IOERR_DELETE            ExtendedErrorCode = xErrorCode(IOERR) | (10 << 8)
	IOERR_BLOCKED           ExtendedErrorCode = xErrorCode(IOERR) | (11 << 8)
	IOERR_NOMEM             ExtendedErrorCode = xErrorCode(IOERR) | (12 << 8)
	IOERR_ACCESS            ExtendedErrorCode = xErrorCode(IOERR) | (13 << 8)
	IOERR_CHECKRESERVEDLOCK ExtendedErrorCode = xErrorCode(IOERR) | (14 << 8)
	IOERR_LOCK              ExtendedErrorCode = xErrorCode(IOERR) | (15 << 8)
	IOERR_CLOSE             ExtendedErrorCode = xErrorCode(IOERR) | (16 << 8)
	IOERR_DIR_CLOSE         ExtendedErrorCode = xErrorCode(IOERR) | (17 << 8)
	IOERR_SHMOPEN           ExtendedErrorCode = xErrorCode(IOERR) | (18 << 8)
	IOERR_SHMSIZE           ExtendedErrorCode = xErrorCode(IOERR) | (19 << 8)
	IOERR_SHMLOCK           ExtendedErrorCode = xErrorCode(IOERR) | (20 << 8)
	IOERR_SHMMAP            ExtendedErrorCode = xErrorCode(IOERR) | (21 << 8)
	IOERR_SEEK              ExtendedErrorCode = xErrorCode(IOERR) | (22 << 8)
	IOERR_DELETE_NOENT      ExtendedErrorCode = xErrorCode(IOERR) | (23 << 8)
	IOERR_MMAP              ExtendedErrorCode = xErrorCode(IOERR) | (24 << 8)
	IOERR_GETTEMPPATH       ExtendedErrorCode = xErrorCode(IOERR) | (25 << 8)
	IOERR_CONVPATH          ExtendedErrorCode = xErrorCode(IOERR) | (26 << 8)
	IOERR_VNODE             ExtendedErrorCode = xErrorCode(IOERR) | (27 << 8)
	IOERR_AUTH              ExtendedErrorCode = xErrorCode(IOERR) | (28 << 8)
	IOERR_BEGIN_ATOMIC      ExtendedErrorCode = xErrorCode(IOERR) | (29 << 8)
	IOERR_COMMIT_ATOMIC     ExtendedErrorCode = xErrorCode(IOERR) | (30 << 8)
	IOERR_ROLLBACK_ATOMIC   ExtendedErrorCode = xErrorCode(IOERR) | (31 << 8)
	IOERR_DATA              ExtendedErrorCode = xErrorCode(IOERR) | (32 << 8)
	IOERR_CORRUPTFS         ExtendedErrorCode = xErrorCode(IOERR) | (33 << 8)
	LOCKED_SHAREDCACHE      ExtendedErrorCode = xErrorCode(LOCKED) | (1 << 8)
	LOCKED_VTAB             ExtendedErrorCode = xErrorCode(LOCKED) | (2 << 8)
	BUSY_RECOVERY           ExtendedErrorCode = xErrorCode(BUSY) | (1 << 8)
	BUSY_SNAPSHOT           ExtendedErrorCode = xErrorCode(BUSY) | (2 << 8)
	BUSY_TIMEOUT            ExtendedErrorCode = xErrorCode(BUSY) | (3 << 8)
	CANTOPEN_NOTEMPDIR      ExtendedErrorCode = xErrorCode(CANTOPEN) | (1 << 8)
	CANTOPEN_ISDIR          ExtendedErrorCode = xErrorCode(CANTOPEN) | (2 << 8)
	CANTOPEN_FULLPATH       ExtendedErrorCode = xErrorCode(CANTOPEN) | (3 << 8)
	CANTOPEN_CONVPATH       ExtendedErrorCode = xErrorCode(CANTOPEN) | (4 << 8)
	CANTOPEN_DIRTYWAL       ExtendedErrorCode = xErrorCode(CANTOPEN) | (5 << 8) /* Not Used */
	CANTOPEN_SYMLINK        ExtendedErrorCode = xErrorCode(CANTOPEN) | (6 << 8)
	CORRUPT_VTAB            ExtendedErrorCode = xErrorCode(CORRUPT) | (1 << 8)
	CORRUPT_SEQUENCE        ExtendedErrorCode = xErrorCode(CORRUPT) | (2 << 8)
	CORRUPT_INDEX           ExtendedErrorCode = xErrorCode(CORRUPT) | (3 << 8)
	READONLY_RECOVERY       ExtendedErrorCode = xErrorCode(READONLY) | (1 << 8)
	READONLY_CANTLOCK       ExtendedErrorCode = xErrorCode(READONLY) | (2 << 8)
	READONLY_ROLLBACK       ExtendedErrorCode = xErrorCode(READONLY) | (3 << 8)
	READONLY_DBMOVED        ExtendedErrorCode = xErrorCode(READONLY) | (4 << 8)
	READONLY_CANTINIT       ExtendedErrorCode = xErrorCode(READONLY) | (5 << 8)
	READONLY_DIRECTORY      ExtendedErrorCode = xErrorCode(READONLY) | (6 << 8)
	ABORT_ROLLBACK          ExtendedErrorCode = xErrorCode(ABORT) | (2 << 8)
	CONSTRAINT_CHECK        ExtendedErrorCode = xErrorCode(CONSTRAINT) | (1 << 8)
	CONSTRAINT_COMMITHOOK   ExtendedErrorCode = xErrorCode(CONSTRAINT) | (2 << 8)
	CONSTRAINT_FOREIGNKEY   ExtendedErrorCode = xErrorCode(CONSTRAINT) | (3 << 8)
	CONSTRAINT_FUNCTION     ExtendedErrorCode = xErrorCode(CONSTRAINT) | (4 << 8)
	CONSTRAINT_NOTNULL      ExtendedErrorCode = xErrorCode(CONSTRAINT) | (5 << 8)
	CONSTRAINT_PRIMARYKEY   ExtendedErrorCode = xErrorCode(CONSTRAINT) | (6 << 8)
	CONSTRAINT_TRIGGER      ExtendedErrorCode = xErrorCode(CONSTRAINT) | (7 << 8)
	CONSTRAINT_UNIQUE       ExtendedErrorCode = xErrorCode(CONSTRAINT) | (8 << 8)
	CONSTRAINT_VTAB         ExtendedErrorCode = xErrorCode(CONSTRAINT) | (9 << 8)
	CONSTRAINT_ROWID        ExtendedErrorCode = xErrorCode(CONSTRAINT) | (10 << 8)
	CONSTRAINT_PINNED       ExtendedErrorCode = xErrorCode(CONSTRAINT) | (11 << 8)
	CONSTRAINT_DATATYPE     ExtendedErrorCode = xErrorCode(CONSTRAINT) | (12 << 8)
	NOTICE_RECOVER_WAL      ExtendedErrorCode = xErrorCode(NOTICE) | (1 << 8)
	NOTICE_RECOVER_ROLLBACK ExtendedErrorCode = xErrorCode(NOTICE) | (2 << 8)
	WARNING_AUTOINDEX       ExtendedErrorCode = xErrorCode(WARNING) | (1 << 8)
	AUTH_USER               ExtendedErrorCode = xErrorCode(AUTH) | (1 << 8)
)

type OpenFlag

type OpenFlag uint32

OpenFlag is a flag for a file open operation.

https://www.sqlite.org/c3ref/c_open_autoproxy.html

const (
	OPEN_READONLY      OpenFlag = 0x00000001 /* Ok for sqlite3_open_v2() */
	OPEN_READWRITE     OpenFlag = 0x00000002 /* Ok for sqlite3_open_v2() */
	OPEN_CREATE        OpenFlag = 0x00000004 /* Ok for sqlite3_open_v2() */
	OPEN_DELETEONCLOSE OpenFlag = 0x00000008 /* VFS only */
	OPEN_EXCLUSIVE     OpenFlag = 0x00000010 /* VFS only */
	OPEN_AUTOPROXY     OpenFlag = 0x00000020 /* VFS only */
	OPEN_URI           OpenFlag = 0x00000040 /* Ok for sqlite3_open_v2() */
	OPEN_MEMORY        OpenFlag = 0x00000080 /* Ok for sqlite3_open_v2() */
	OPEN_MAIN_DB       OpenFlag = 0x00000100 /* VFS only */
	OPEN_TEMP_DB       OpenFlag = 0x00000200 /* VFS only */
	OPEN_TRANSIENT_DB  OpenFlag = 0x00000400 /* VFS only */
	OPEN_MAIN_JOURNAL  OpenFlag = 0x00000800 /* VFS only */
	OPEN_TEMP_JOURNAL  OpenFlag = 0x00001000 /* VFS only */
	OPEN_SUBJOURNAL    OpenFlag = 0x00002000 /* VFS only */
	OPEN_SUPER_JOURNAL OpenFlag = 0x00004000 /* VFS only */
	OPEN_NOMUTEX       OpenFlag = 0x00008000 /* Ok for sqlite3_open_v2() */
	OPEN_FULLMUTEX     OpenFlag = 0x00010000 /* Ok for sqlite3_open_v2() */
	OPEN_SHAREDCACHE   OpenFlag = 0x00020000 /* Ok for sqlite3_open_v2() */
	OPEN_PRIVATECACHE  OpenFlag = 0x00040000 /* Ok for sqlite3_open_v2() */
	OPEN_WAL           OpenFlag = 0x00080000 /* VFS only */
	OPEN_NOFOLLOW      OpenFlag = 0x01000000 /* Ok for sqlite3_open_v2() */
	OPEN_EXRESCODE     OpenFlag = 0x02000000 /* Extended result codes */
)

type PrepareFlag

type PrepareFlag uint32

PrepareFlag is a flag that can be passed to Conn.PrepareFlags.

https://www.sqlite.org/c3ref/c_prepare_normalize.html

const (
	PREPARE_PERSISTENT PrepareFlag = 0x01
	PREPARE_NORMALIZE  PrepareFlag = 0x02
	PREPARE_NO_VTAB    PrepareFlag = 0x04
)

type Stmt

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

Stmt is a prepared statement object.

https://www.sqlite.org/c3ref/stmt.html

func (*Stmt) BindBlob

func (s *Stmt) BindBlob(param int, value []byte) error

BindBlob binds a []byte to the prepared statement. The leftmost SQL parameter has an index of 1. Binding a nil slice is the same as calling Stmt.BindNull.

https://www.sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindBool

func (s *Stmt) BindBool(param int, value bool) error

BindBool binds a bool to the prepared statement. The leftmost SQL parameter has an index of 1. SQLite does not have a separate boolean storage class. Instead, boolean values are stored as integers 0 (false) and 1 (true).

https://www.sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindCount added in v0.2.0

func (s *Stmt) BindCount() int

BindCount returns the number of SQL parameters in the prepared statement.

https://www.sqlite.org/c3ref/bind_parameter_count.html

func (*Stmt) BindFloat

func (s *Stmt) BindFloat(param int, value float64) error

BindFloat binds a float64 to the prepared statement. The leftmost SQL parameter has an index of 1.

https://www.sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindIndex added in v0.2.0

func (s *Stmt) BindIndex(name string) int

BindIndex returns the index of a parameter in the prepared statement given its name.

https://www.sqlite.org/c3ref/bind_parameter_index.html

func (*Stmt) BindInt

func (s *Stmt) BindInt(param int, value int) error

BindInt binds an int to the prepared statement. The leftmost SQL parameter has an index of 1.

https://www.sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindInt64

func (s *Stmt) BindInt64(param int, value int64) error

BindInt64 binds an int64 to the prepared statement. The leftmost SQL parameter has an index of 1.

https://www.sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindName added in v0.2.0

func (s *Stmt) BindName(param int) string

BindName returns the name of a parameter in the prepared statement. The leftmost SQL parameter has an index of 1.

https://www.sqlite.org/c3ref/bind_parameter_name.html

func (*Stmt) BindNull

func (s *Stmt) BindNull(param int) error

BindNull binds a NULL to the prepared statement. The leftmost SQL parameter has an index of 1.

https://www.sqlite.org/c3ref/bind_blob.html

func (*Stmt) BindText

func (s *Stmt) BindText(param int, value string) error

BindText binds a string to the prepared statement. The leftmost SQL parameter has an index of 1.

https://www.sqlite.org/c3ref/bind_blob.html

func (*Stmt) ClearBindings

func (s *Stmt) ClearBindings() error

ClearBindings resets all bindings on the prepared statement.

https://www.sqlite.org/c3ref/clear_bindings.html

func (*Stmt) Close

func (s *Stmt) Close() error

Close destroys the prepared statement object.

https://www.sqlite.org/c3ref/finalize.html

func (*Stmt) ColumnBlob

func (s *Stmt) ColumnBlob(col int, buf []byte) []byte

ColumnBlob appends to buf and returns the value of the result column as a []byte. The leftmost column of the result set has the index 0.

https://www.sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnBool

func (s *Stmt) ColumnBool(col int) bool

ColumnBool returns the value of the result column as a bool. The leftmost column of the result set has the index 0. SQLite does not have a separate boolean storage class. Instead, boolean values are retrieved as integers, with 0 converted to false and any other value to true.

https://www.sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnCount added in v0.2.0

func (s *Stmt) ColumnCount() int

ColumnCount returns the number of columns in a result set.

https://www.sqlite.org/c3ref/column_count.html

func (*Stmt) ColumnFloat

func (s *Stmt) ColumnFloat(col int) float64

ColumnFloat returns the value of the result column as a float64. The leftmost column of the result set has the index 0.

https://www.sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnInt

func (s *Stmt) ColumnInt(col int) int

ColumnInt returns the value of the result column as an int. The leftmost column of the result set has the index 0.

https://www.sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnInt64

func (s *Stmt) ColumnInt64(col int) int64

ColumnInt64 returns the value of the result column as an int64. The leftmost column of the result set has the index 0.

https://www.sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnName added in v0.2.0

func (s *Stmt) ColumnName(col int) string

ColumnName returns the name of the result column. The leftmost column of the result set has the index 0.

https://www.sqlite.org/c3ref/column_name.html

func (*Stmt) ColumnText

func (s *Stmt) ColumnText(col int) string

ColumnText returns the value of the result column as a string. The leftmost column of the result set has the index 0.

https://www.sqlite.org/c3ref/column_blob.html

func (*Stmt) ColumnType

func (s *Stmt) ColumnType(col int) Datatype

ColumnType returns the initial Datatype of the result column. The leftmost column of the result set has the index 0.

https://www.sqlite.org/c3ref/column_blob.html

func (*Stmt) Err

func (s *Stmt) Err() error

Err gets the last error occurred during Stmt.Step. Err returns nil after Stmt.Reset is called.

https://www.sqlite.org/c3ref/step.html

func (*Stmt) Exec

func (s *Stmt) Exec() error

Exec is a convenience function that repeatedly calls Stmt.Step until it returns false, then calls Stmt.Reset to reset the statement and get any error that occurred.

func (*Stmt) Reset

func (s *Stmt) Reset() error

Reset resets the prepared statement object.

https://www.sqlite.org/c3ref/reset.html

func (*Stmt) Step

func (s *Stmt) Step() bool

Step evaluates the SQL statement. If the SQL statement being executed returns any data, then true is returned each time a new row of data is ready for processing by the caller. The values may be accessed using the Column access functions. Step is called again to retrieve the next row of data. If an error has occurred, Step returns false; call Stmt.Err or Stmt.Reset to get the error.

https://www.sqlite.org/c3ref/step.html

Directories

Path Synopsis
Package driver provides a database/sql driver for SQLite.
Package driver provides a database/sql driver for SQLite.
Package embed embeds SQLite into your application.
Package embed embeds SQLite into your application.
bcw2 Module
gormlite module

Jump to

Keyboard shortcuts

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