2018-06-15 18:53:32 +03:00
|
|
|
// Copyright (C) 2018 The Go-SQLite3 Authors.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by an MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2018-06-19 18:53:53 +03:00
|
|
|
// +build cgo
|
2018-06-15 18:53:32 +03:00
|
|
|
// +build go1.10
|
|
|
|
|
|
|
|
package sqlite3
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"database/sql/driver"
|
|
|
|
)
|
|
|
|
|
2018-06-19 18:53:53 +03:00
|
|
|
var (
|
2018-06-23 10:42:05 +03:00
|
|
|
_ driver.Connector = (*Config)(nil)
|
2018-06-19 18:53:53 +03:00
|
|
|
)
|
|
|
|
|
2018-06-15 18:53:32 +03:00
|
|
|
// Connect implements driver.Connector interface.
|
|
|
|
// Connect returns a connection to the database.
|
2018-06-23 10:42:05 +03:00
|
|
|
func (c *Config) Connect(ctx context.Context) (driver.Conn, error) {
|
|
|
|
return c.createConnection()
|
2018-06-15 18:53:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Driver implements driver.Connector interface.
|
2018-06-23 10:42:05 +03:00
|
|
|
// Driver returns &SQLiteDriver{}.
|
|
|
|
func (c *Config) Driver() driver.Driver {
|
|
|
|
return &SQLiteDriver{
|
2018-06-24 23:57:57 +03:00
|
|
|
Config: c,
|
|
|
|
Extensions: c.Extensions,
|
|
|
|
ConnectHook: c.ConnectHook,
|
2018-06-23 10:42:05 +03:00
|
|
|
}
|
2018-06-15 18:53:32 +03:00
|
|
|
}
|