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
|
2018-06-19 18:53:53 +03:00
|
|
|
|
2018-06-24 23:57:57 +03:00
|
|
|
import (
|
|
|
|
"database/sql/driver"
|
|
|
|
)
|
2018-06-19 18:53:53 +03:00
|
|
|
|
|
|
|
var (
|
|
|
|
_ driver.DriverContext = (*SQLiteDriver)(nil)
|
|
|
|
)
|
|
|
|
|
|
|
|
// OpenConnector will call OpenConnector to obtain a Connector and then invoke
|
|
|
|
// that Connector's Conn method to obtain each needed connection,
|
|
|
|
// instead of invoking the Driver's Open method for each connection.
|
|
|
|
// The two-step sequence allows drivers to parse the name just once and also provides
|
|
|
|
// access to per-Conn contexts.
|
2018-06-23 10:42:05 +03:00
|
|
|
func (d *SQLiteDriver) OpenConnector(dsn string) (driver.Connector, error) {
|
2018-07-03 14:49:21 +03:00
|
|
|
d.mu.Lock()
|
|
|
|
defer d.mu.Unlock()
|
|
|
|
|
2018-06-24 23:57:57 +03:00
|
|
|
cfg, err := ParseDSN(dsn)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Configure Extensions
|
|
|
|
cfg.Extensions = d.Extensions
|
|
|
|
|
|
|
|
// Configure ConnectHook
|
|
|
|
cfg.ConnectHook = d.ConnectHook
|
|
|
|
|
|
|
|
// Set Configuration
|
|
|
|
d.Config = cfg
|
|
|
|
|
|
|
|
return cfg, nil
|
2018-06-19 18:53:53 +03:00
|
|
|
}
|