aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYasuhiro Matsumoto <mattn.jp@gmail.com>2016-11-04 15:11:24 +0900
committerYasuhiro Matsumoto <mattn.jp@gmail.com>2016-11-04 15:11:24 +0900
commit025b917610cf628e9be1dcf9386525d0dbc22659 (patch)
treed07015c8f2199a5dce8e647bda486c42e34bb90a
parentbuild tag (diff)
downloadgolite-025b917610cf628e9be1dcf9386525d0dbc22659.tar.gz
golite-025b917610cf628e9be1dcf9386525d0dbc22659.tar.xz
add PrepareContext
-rw-r--r--sqlite3.go4
-rw-r--r--sqlite3_go18.go4
2 files changed, 8 insertions, 0 deletions
diff --git a/sqlite3.go b/sqlite3.go
index 3b80eeb..bef5627 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -644,6 +644,10 @@ func (c *SQLiteConn) Close() error {
// Prepare the query string. Return a new statement.
func (c *SQLiteConn) Prepare(query string) (driver.Stmt, error) {
+ return c.prepare(context.Background(), query)
+}
+
+func (c *SQLiteConn) prepare(ctx context.Context, query string) (driver.Stmt, error) {
pquery := C.CString(query)
defer C.free(unsafe.Pointer(pquery))
var s *C.sqlite3_stmt
diff --git a/sqlite3_go18.go b/sqlite3_go18.go
index 28a1bbf..5832a92 100644
--- a/sqlite3_go18.go
+++ b/sqlite3_go18.go
@@ -33,6 +33,10 @@ func (c *SQLiteConn) ExecContext(ctx context.Context, query string, args []drive
return c.exec(ctx, query, list)
}
+func (c *SQLiteConn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
+ return c.prepare(ctx, query)
+}
+
func (s *SQLiteStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
list := make([]namedValue, len(args))
for i, nv := range args {