-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_db.go
More file actions
48 lines (38 loc) · 1020 Bytes
/
debug_db.go
File metadata and controls
48 lines (38 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"database/sql"
"fmt"
"log"
"os"
_ "github.com/mattn/go-sqlite3"
)
func main() {
fmt.Println("Testing database connection...")
// Check current directory
pwd, _ := os.Getwd()
fmt.Printf("Current directory: %s\n", pwd)
// Check if data directory exists
if _, err := os.Stat("data"); os.IsNotExist(err) {
fmt.Println("data directory does not exist")
} else {
fmt.Println("data directory exists")
}
// Check if database file exists
if _, err := os.Stat("data/helixflow.db"); os.IsNotExist(err) {
fmt.Println("database file does not exist")
} else {
fmt.Println("database file exists")
}
// Try to open database
db, err := sql.Open("sqlite3", "data/helixflow.db")
if err != nil {
log.Fatalf("Failed to open database: %v", err)
}
defer db.Close()
fmt.Printf("Database opened: %v\n", db != nil)
// Test connection
if err := db.Ping(); err != nil {
log.Fatalf("Failed to ping database: %v", err)
}
fmt.Println("✅ Database connection successful")
}