MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / New

Function New

internal/db/db.go:38–53  ·  view source on GitHub ↗

New opens (or creates) the SQLite database and runs migrations.

()

Source from the content-addressed store, hash-verified

36
37// New opens (or creates) the SQLite database and runs migrations.
38func New() (*DB, error) {
39 p, err := config.DBPath()
40 if err != nil {
41 return nil, err
42 }
43 conn, err := sql.Open("sqlite", p)
44 if err != nil {
45 return nil, fmt.Errorf("failed to open database: %w", err)
46 }
47 d := &DB{conn: conn}
48 if err := d.initTables(); err != nil {
49 conn.Close()
50 return nil, err
51 }
52 return d, nil
53}
54
55// Close closes the database connection.
56func (d *DB) Close() error {

Callers 4

NewAppFunction · 0.92
runCacheClearFunction · 0.92
runCacheStatsFunction · 0.92
runHistoryFunction · 0.92

Calls 3

initTablesMethod · 0.95
DBPathFunction · 0.92
CloseMethod · 0.80

Tested by

no test coverage detected