add PrepareContext
This commit is contained in:
parent
29b191f206
commit
025b917610
|
@ -644,6 +644,10 @@ func (c *SQLiteConn) Close() error {
|
||||||
|
|
||||||
// Prepare the query string. Return a new statement.
|
// Prepare the query string. Return a new statement.
|
||||||
func (c *SQLiteConn) Prepare(query string) (driver.Stmt, error) {
|
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)
|
pquery := C.CString(query)
|
||||||
defer C.free(unsafe.Pointer(pquery))
|
defer C.free(unsafe.Pointer(pquery))
|
||||||
var s *C.sqlite3_stmt
|
var s *C.sqlite3_stmt
|
||||||
|
|
|
@ -33,6 +33,10 @@ func (c *SQLiteConn) ExecContext(ctx context.Context, query string, args []drive
|
||||||
return c.exec(ctx, query, list)
|
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) {
|
func (s *SQLiteStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
|
||||||
list := make([]namedValue, len(args))
|
list := make([]namedValue, len(args))
|
||||||
for i, nv := range args {
|
for i, nv := range args {
|
||||||
|
|
Loading…
Reference in New Issue