Skip to content

Commit

Permalink
merging upstream mattn/go-sqlite3 into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Engelhardt committed Apr 5, 2012
2 parents 7eefaf9 + 5691b2a commit 3c3e9fd
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
16 changes: 16 additions & 0 deletions .travis.yml
@@ -0,0 +1,16 @@
language: erlang # wither art thou, Go?

install:
- hg clone -r weekly https://code.google.com/p/go $HOME/go
- cd $HOME/go/src && ./make.bash
- mkdir -p $HOME/src || true
- mkdir -p $HOME/bin || true
- mkdir -p $HOME/pkg || true
- export GOPATH=$HOME
- export PATH=$PATH:$HOME/go/bin
- ln -s $HOME/builds/mattn/go-sqlite3 $HOME/src/go-sqlite3
- go get -v github.com/mattn/go-sqlite3

script:
- cd $HOME/src/go-sqlite3 && go build -v .
- cd $HOME/src/go-sqlite3 && go test -v .
12 changes: 11 additions & 1 deletion README.mkd
Expand Up @@ -6,7 +6,17 @@ DESCRIPTION

sqlite3 driver for go that using database/sql

INSTALLATION
------------

It require `pkg-config`. And need to be possible to get information with `pkg-config --cflags --libs sqlite3`.
If you are using Windows, you can get pkg-config from below.

http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/

Go does not support static linkage for external C library. So you should build sqlite3 with shared library. If it run on windows, it need dll.

LICENSE
-------

MIT: http://mattn.mit-license.org/2011
MIT: http://mattn.mit-license.org/2012
14 changes: 12 additions & 2 deletions sqlite3.go
Expand Up @@ -91,6 +91,12 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
if db == nil {
return nil, errors.New("sqlite succeeded without returning a database")
}

rv = C.sqlite3_busy_timeout(db, 500)
if rv != C.SQLITE_OK {
return nil, errors.New(C.GoString(C.sqlite3_errmsg(db)))
}

return &SQLiteConn{db}, nil
}

Expand Down Expand Up @@ -174,7 +180,7 @@ func (s *SQLiteStmt) bind(args []driver.Value) error {
rv = C.sqlite3_bind_int(s.s, n, C.int(v))
case bool:
if bool(v) {
rv = C.sqlite3_bind_int(s.s, n, -1)
rv = C.sqlite3_bind_int(s.s, n, 1)
} else {
rv = C.sqlite3_bind_int(s.s, n, 0)
}
Expand Down Expand Up @@ -233,7 +239,11 @@ type SQLiteRows struct {
}

func (rc *SQLiteRows) Close() error {
return rc.s.Close()
rv := C.sqlite3_reset(rc.s.s)
if rv != C.SQLITE_OK {
return errors.New(C.GoString(C.sqlite3_errmsg(rc.s.c.db)))
}
return nil
}

func (rc *SQLiteRows) Columns() []string {
Expand Down

0 comments on commit 3c3e9fd

Please sign in to comment.