sqlite_go18.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2017 The Sqlite Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. //go:build go1.8
  5. // +build go1.8
  6. package sqlite // import "modernc.org/sqlite"
  7. import (
  8. "context"
  9. "database/sql/driver"
  10. )
  11. // Ping implements driver.Pinger
  12. func (c *conn) Ping(ctx context.Context) error {
  13. _, err := c.ExecContext(ctx, "select 1", nil)
  14. return err
  15. }
  16. // BeginTx implements driver.ConnBeginTx
  17. func (c *conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
  18. return c.begin(ctx, opts)
  19. }
  20. // PrepareContext implements driver.ConnPrepareContext
  21. func (c *conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
  22. return c.prepare(ctx, query)
  23. }
  24. // ExecContext implements driver.ExecerContext
  25. func (c *conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
  26. return c.exec(ctx, query, args)
  27. }
  28. // QueryContext implements driver.QueryerContext
  29. func (c *conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
  30. return c.query(ctx, query, args)
  31. }
  32. // ExecContext implements driver.StmtExecContext
  33. func (s *stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
  34. return s.exec(ctx, args)
  35. }
  36. // QueryContext implements driver.StmtQueryContext
  37. func (s *stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
  38. return s.query(ctx, args)
  39. }