Commit a9c8e3d9 authored by gwenn's avatar gwenn

Add Unwrap method.

parent 5a06a445
......@@ -56,6 +56,15 @@ func (d *impl) Open(name string) (driver.Conn, error) {
return &conn{c}, nil
}
// Unwrap gives access to underlying driver connection.
func Unwrap(db *sql.DB) *Conn {
_, err := db.Exec("unwrap")
if cerr, ok := err.(*ConnError); ok {
return cerr.c
}
return nil
}
// PRAGMA schema_version may be used to detect when the database schema is altered
func (c *conn) Exec(query string, args []driver.Value) (driver.Result, error) {
......
......@@ -6,8 +6,10 @@ package sqlite_test
import (
"database/sql"
"github.com/bmizerany/assert"
"testing"
"github.com/bmizerany/assert"
"github.com/gwenn/gosqlite"
)
const (
......@@ -162,3 +164,11 @@ func TestRowsWithStmtClosed(t *testing.T) {
checkNoError(t, err, "Error while scanning: %s")
}
}
func TestUnwrap(t *testing.T) {
db := sqlOpen(t)
conn := sqlite.Unwrap(db)
assert.Tf(t, conn != nil, "Expecting *sqlite.Conn but got %#v", conn)
// fmt.Printf("%#v\n", conn)
conn.TotalChanges()
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment