OSDN Git Service

add sqlite vendor (#48)
[bytom/vapor.git] / vendor / github.com / mattn / go-sqlite3 / sqlite3_go18.go
1 // Copyright (C) 2014 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 // +build cgo
7 // +build go1.8
8
9 package sqlite3
10
11 import (
12         "database/sql/driver"
13         "errors"
14
15         "context"
16 )
17
18 // Ping implement Pinger.
19 func (c *SQLiteConn) Ping(ctx context.Context) error {
20         if c.db == nil {
21                 return errors.New("Connection was closed")
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         list := make([]namedValue, len(args))
29         for i, nv := range args {
30                 list[i] = namedValue(nv)
31         }
32         return c.query(ctx, query, list)
33 }
34
35 // ExecContext implement ExecerContext.
36 func (c *SQLiteConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
37         list := make([]namedValue, len(args))
38         for i, nv := range args {
39                 list[i] = namedValue(nv)
40         }
41         return c.exec(ctx, query, list)
42 }
43
44 // PrepareContext implement ConnPrepareContext.
45 func (c *SQLiteConn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
46         return c.prepare(ctx, query)
47 }
48
49 // BeginTx implement ConnBeginTx.
50 func (c *SQLiteConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
51         return c.begin(ctx)
52 }
53
54 // QueryContext implement QueryerContext.
55 func (s *SQLiteStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
56         list := make([]namedValue, len(args))
57         for i, nv := range args {
58                 list[i] = namedValue(nv)
59         }
60         return s.query(ctx, list)
61 }
62
63 // ExecContext implement ExecerContext.
64 func (s *SQLiteStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
65         list := make([]namedValue, len(args))
66         for i, nv := range args {
67                 list[i] = namedValue(nv)
68         }
69         return s.exec(ctx, list)
70 }