MCPcopy Create free account
hub / github.com/AdRoll/baker / setup

Method setup

output/sqlite.go:163–200  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

161}
162
163func (c *SQLite) setup() error {
164 var err error
165
166 defer func() {
167 if err != nil && c.conn != nil {
168 c.conn.Close()
169 }
170 }()
171
172 if err = c.vetIdentifiers(); err != nil {
173 return err
174 }
175
176 // Set up database handle
177 c.conn, err = sql.Open("sqlite3", c.pathString)
178 if err != nil {
179 return fmt.Errorf("sql.Open: %s", err)
180 }
181
182 if err = c.setDBSettings(c.conn); err != nil {
183 return fmt.Errorf("set global settings: %s", err)
184 }
185
186 // Open transaction. The entire thing will run in just this one
187 // transaction.
188 c.tx, err = c.conn.Begin()
189 if err != nil {
190 return fmt.Errorf("cannot start transaction: %s", err)
191 }
192
193 // Run the pre-run commands
194 if err = runSQLCommands(c.tx, c.cfg.PreRun); err != nil {
195 c.tx.Rollback()
196 return fmt.Errorf("cannot run pre-SQL commands: %s", err)
197 }
198
199 return nil
200}
201
202// isPrintable reports whether a string contains only printable runes.
203func isPrintable(str string) bool {

Callers 1

NewSQLiteFunction · 0.95

Calls 4

vetIdentifiersMethod · 0.95
setDBSettingsMethod · 0.95
runSQLCommandsFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected