MCPcopy Create free account
hub / github.com/Adaptix-Framework/AdaptixC2 / NewDatabase

Function NewDatabase

AdaptixServer/core/database/database.go:19–48  ·  view source on GitHub ↗
(dbPath string)

Source from the content-addressed store, hash-verified

17}
18
19func NewDatabase(dbPath string) (*DBMS, error) {
20 var err error
21
22 dbms := &DBMS{
23 exists: true,
24 }
25
26 // Enable WAL mode and other performance optimizations via connection string
27 connStr := dbPath + "?_journal_mode=WAL&_synchronous=NORMAL&_busy_timeout=10000&_cache_size=-64000"
28 dbms.database, err = sql.Open("sqlite3", connStr)
29 if err != nil {
30 dbms.exists = false
31 }
32
33 if dbms.exists {
34 dbms.database.SetMaxOpenConns(1)
35 dbms.database.SetMaxIdleConns(1)
36
37 err = dbms.DatabaseInit()
38 if err != nil {
39 dbms.exists = false
40 }
41 }
42
43 if dbms.exists {
44 dbms.prepareStatements()
45 }
46
47 return dbms, err
48}
49
50func (dbms *DBMS) prepareStatements() {
51 var err error

Callers

nothing calls this directly

Calls 2

DatabaseInitMethod · 0.95
prepareStatementsMethod · 0.95

Tested by

no test coverage detected