sqlite3_go18.go raw

   1  // Copyright (C) 2019 Yasuhiro Matsumoto <mattn.jp@gmail.com>.
   2  //
   3  // Use of this source code is governed by an MIT-style
   4  // license that can be found in the LICENSE file.
   5  
   6  //go:build cgo && go1.8
   7  // +build cgo,go1.8
   8  
   9  package sqlite3
  10  
  11  import (
  12  	"database/sql/driver"
  13  
  14  	"context"
  15  )
  16  
  17  // Ping implement Pinger.
  18  func (c *SQLiteConn) Ping(ctx context.Context) error {
  19  	if c.db == nil {
  20  		// must be ErrBadConn for sql to close the database
  21  		return driver.ErrBadConn
  22  	}
  23  	return nil
  24  }
  25  
  26  // QueryContext implement QueryerContext.
  27  func (c *SQLiteConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
  28  	return c.query(ctx, query, args)
  29  }
  30  
  31  // ExecContext implement ExecerContext.
  32  func (c *SQLiteConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
  33  	return c.exec(ctx, query, args)
  34  }
  35  
  36  // PrepareContext implement ConnPrepareContext.
  37  func (c *SQLiteConn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
  38  	return c.prepare(ctx, query)
  39  }
  40  
  41  // BeginTx implement ConnBeginTx.
  42  func (c *SQLiteConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
  43  	return c.begin(ctx)
  44  }
  45  
  46  // QueryContext implement QueryerContext.
  47  func (s *SQLiteStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
  48  	return s.query(ctx, args)
  49  }
  50  
  51  // ExecContext implement ExecerContext.
  52  func (s *SQLiteStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
  53  	return s.exec(ctx, args)
  54  }
  55