MCPcopy Create free account
hub / github.com/compozy/agh / configureSQLite

Function configureSQLite

internal/store/sqlite.go:135–156  ·  view source on GitHub ↗
(ctx context.Context, db *sql.DB)

Source from the content-addressed store, hash-verified

133}
134
135func configureSQLite(ctx context.Context, db *sql.DB) error {
136 if _, err := db.ExecContext(ctx, fmt.Sprintf("PRAGMA busy_timeout = %d", defaultBusyTimeoutMS)); err != nil {
137 return err
138 }
139
140 mode, err := querySingleString(ctx, db, "PRAGMA journal_mode = WAL")
141 if err != nil {
142 return err
143 }
144 if !strings.EqualFold(mode, "wal") {
145 return fmt.Errorf("store: sqlite journal_mode = %q, want wal", mode)
146 }
147
148 if _, err := db.ExecContext(ctx, "PRAGMA synchronous = NORMAL"); err != nil {
149 return err
150 }
151 if _, err := db.ExecContext(ctx, "PRAGMA foreign_keys = ON"); err != nil {
152 return err
153 }
154
155 return nil
156}
157
158func querySingleString(ctx context.Context, db *sql.DB, stmt string) (string, error) {
159 var value string

Callers 2

openSQLiteDatabaseOnceFunction · 0.85
TestStoreSQLiteHelpersFunction · 0.85

Calls 2

querySingleStringFunction · 0.85
ExecContextMethod · 0.65

Tested by 1

TestStoreSQLiteHelpersFunction · 0.68