MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / checkSQLiteRestoreDatabase

Function checkSQLiteRestoreDatabase

cmd/pad/db_restore_sqlite.go:209–228  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

207}
208
209func checkSQLiteRestoreDatabase(path string) error {
210 dsn, err := sqliteFileURI(path)
211 if err != nil {
212 return err
213 }
214 db, err := sql.Open("sqlite", dsn)
215 if err != nil {
216 return err
217 }
218 var result string
219 err = db.QueryRow("PRAGMA quick_check").Scan(&result)
220 err = errors.Join(err, db.Close())
221 if err != nil {
222 return err
223 }
224 if result != "ok" {
225 return fmt.Errorf("SQLite quick_check: %s", result)
226 }
227 return nil
228}
229
230// Escape filesystem names rather than letting SQLite interpret '?' or '#' as
231// connection options. Windows drive paths need a leading slash in file URIs.

Callers 1

restoreSQLiteFunction · 0.85

Calls 6

sqliteFileURIFunction · 0.85
JoinMethod · 0.80
ScanMethod · 0.65
QueryRowMethod · 0.65
CloseMethod · 0.65
OpenMethod · 0.45

Tested by

no test coverage detected