sqlite3

package
v0.2.1 Latest Latest
Warning

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

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

README

go-sqlite3
==========

[![Build Status](https://travis-ci.org/mattn/go-sqlite3.png?branch=master)](https://travis-ci.org/mattn/go-sqlite3)
[![Coverage Status](https://coveralls.io/repos/mattn/go-sqlite3/badge.png?branch=master)](https://coveralls.io/r/mattn/go-sqlite3?branch=master)

Description
-----------

sqlite3 driver conforming to the built-in database/sql interface

Installation
------------

This package can be installed with the go get command:

    go get github.com/mattn/go-sqlite3
    
Documentation
-------------

API documentation can be found here: http://godoc.org/github.com/mattn/go-sqlite3

Examples can be found under the `./_example` directory

FAQ
---

* Can't build go-sqlite3 on windows 64bit.

    > Probably, you are using go 1.0, go1.0 has a problem when it comes to compiling/linking on windows 64bit. 
    > See: https://github.com/mattn/go-sqlite3/issues/27

* Getting insert error while query is opened.

    > You can pass some arguments into the connection string, for example, a URI.
    > See: https://github.com/mattn/go-sqlite3/issues/39

License
-------

MIT: http://mattn.mit-license.org/2012

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrError      error = ErrNo(1)  /* SQL error or missing database */
	ErrInternal   error = ErrNo(2)  /* Internal logic error in SQLite */
	ErrPerm       error = ErrNo(3)  /* Access permission denied */
	ErrAbort      error = ErrNo(4)  /* Callback routine requested an abort */
	ErrBusy       error = ErrNo(5)  /* The database file is locked */
	ErrLocked     error = ErrNo(6)  /* A table in the database is locked */
	ErrNomem      error = ErrNo(7)  /* A malloc() failed */
	ErrReadonly   error = ErrNo(8)  /* Attempt to write a readonly database */
	ErrInterrupt  error = ErrNo(9)  /* Operation terminated by sqlite3_interrupt() */
	ErrIoErr      error = ErrNo(10) /* Some kind of disk I/O error occurred */
	ErrCorrupt    error = ErrNo(11) /* The database disk image is malformed */
	ErrNotFound   error = ErrNo(12) /* Unknown opcode in sqlite3_file_control() */
	ErrFull       error = ErrNo(13) /* Insertion failed because database is full */
	ErrCantOpen   error = ErrNo(14) /* Unable to open the database file */
	ErrProtocol   error = ErrNo(15) /* Database lock protocol error */
	ErrEmpty      error = ErrNo(16) /* Database is empty */
	ErrSchema     error = ErrNo(17) /* The database schema changed */
	ErrTooBig     error = ErrNo(18) /* String or BLOB exceeds size limit */
	ErrConstraint error = ErrNo(19) /* Abort due to constraint violation */
	ErrMismatch   error = ErrNo(20) /* Data type mismatch */
	ErrMisuse     error = ErrNo(21) /* Library used incorrectly */
	ErrNoLFS      error = ErrNo(22) /* Uses OS features not supported on host */
	ErrAuth       error = ErrNo(23) /* Authorization denied */
	ErrFormat     error = ErrNo(24) /* Auxiliary database format error */
	ErrRange      error = ErrNo(25) /* 2nd parameter to sqlite3_bind out of range */
	ErrNotADB     error = ErrNo(26) /* File opened that is not a database file */
	ErrNotice     error = ErrNo(27) /* Notifications from sqlite3_log() */
	ErrWarning    error = ErrNo(28) /* Warnings from sqlite3_log() */
)

result codes from http://www.sqlite.org/c3ref/c_abort.html

View Source
var SQLiteTimestampFormats = []string{
	"2006-01-02 15:04:05.999999999",
	"2006-01-02T15:04:05.999999999",
	"2006-01-02 15:04:05",
	"2006-01-02T15:04:05",
	"2006-01-02 15:04",
	"2006-01-02T15:04",
	"2006-01-02",
}

Timestamp formats understood by both this module and SQLite. The first format in the slice will be used when saving time values into the database. When parsing a string from a timestamp or datetime column, the formats are tried in order.

Functions

This section is empty.

Types

type Backup

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

func (*Backup) Finish

func (b *Backup) Finish() error

func (*Backup) PageCount

func (b *Backup) PageCount() int

func (*Backup) Remaining

func (b *Backup) Remaining() int

func (*Backup) Step

func (b *Backup) Step(p int) error

type ErrNo

type ErrNo int

func (ErrNo) Error

func (err ErrNo) Error() string

type Error

type Error struct {
	Code ErrNo /* The error code returned by SQLite */
	// contains filtered or unexported fields
}

func (Error) Error

func (err Error) Error() string

type SQLiteConn

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

Conn struct.

func (*SQLiteConn) AutoCommit

func (c *SQLiteConn) AutoCommit() bool

AutoCommit return which currently auto commit or not.

func (*SQLiteConn) Backup

func (c *SQLiteConn) Backup(dest string, conn *SQLiteConn, src string) (*Backup, error)

func (*SQLiteConn) Begin

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

Begin transaction.

func (*SQLiteConn) Close

func (c *SQLiteConn) Close() error

Close the connection.

func (*SQLiteConn) Prepare

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

Prepare query string. Return a new statement.

type SQLiteDriver

type SQLiteDriver struct {
	Extensions  []string
	ConnectHook func(*SQLiteConn) error
}

Driver struct.

func (*SQLiteDriver) Open

func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error)

Open database and return a new connection. You can specify DSN string with URI filename.

test.db
file:test.db?cache=shared&mode=memory
:memory:
file::memory:

type SQLiteResult

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

Result struct.

func (*SQLiteResult) LastInsertId

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

Return last inserted ID.

func (*SQLiteResult) RowsAffected

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

Return how many rows affected.

type SQLiteRows

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

Rows struct.

func (*SQLiteRows) Close

func (rc *SQLiteRows) Close() error

Close the rows.

func (*SQLiteRows) Columns

func (rc *SQLiteRows) Columns() []string

Return column names.

func (*SQLiteRows) Next

func (rc *SQLiteRows) Next(dest []driver.Value) error

Move cursor to next.

type SQLiteStmt

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

Stmt struct.

func (*SQLiteStmt) Close

func (s *SQLiteStmt) Close() error

Close the statement.

func (*SQLiteStmt) Exec

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

Execute the statement with arguments. Return result object.

func (*SQLiteStmt) NumInput

func (s *SQLiteStmt) NumInput() int

Return a number of parameters.

func (*SQLiteStmt) Query

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

Query the statement with arguments. Return records.

type SQLiteTx

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

Tx struct.

func (*SQLiteTx) Commit

func (tx *SQLiteTx) Commit() error

Commit transaction.

func (*SQLiteTx) Rollback

func (tx *SQLiteTx) Rollback() error

Rollback transaction.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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