newDB returns an instance of DB, which is a logical connection to the underlying sqlite database
( dbKind sqlplugin.DbKind, dbName string, xdb *sqlx.DB, tx *sqlx.Tx, logger log.Logger, )
| 33 | // newDB returns an instance of DB, which is a logical |
| 34 | // connection to the underlying sqlite database |
| 35 | func newDB( |
| 36 | dbKind sqlplugin.DbKind, |
| 37 | dbName string, |
| 38 | xdb *sqlx.DB, |
| 39 | tx *sqlx.Tx, |
| 40 | logger log.Logger, |
| 41 | ) *db { |
| 42 | mdb := &db{ |
| 43 | dbKind: dbKind, |
| 44 | dbName: dbName, |
| 45 | onClose: make([]func(), 0), |
| 46 | db: xdb, |
| 47 | tx: tx, |
| 48 | logger: logger, |
| 49 | } |
| 50 | mdb.conn = xdb |
| 51 | if tx != nil { |
| 52 | mdb.conn = tx |
| 53 | } |
| 54 | mdb.converter = &converter{} |
| 55 | return mdb |
| 56 | } |
| 57 | |
| 58 | // BeginTx starts a new transaction and returns a reference to the Tx object |
| 59 | func (mdb *db) BeginTx(ctx context.Context) (sqlplugin.Tx, error) { |
no outgoing calls