summaryrefslogtreecommitdiff
path: root/database/conn.go
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2025-01-05 16:39:13 -0800
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2025-01-05 16:39:13 -0800
commitd25ec27fb1c3df175e1b98af1fdc26881d68a1ab (patch)
treea79c729b92c0d0a52b19b37c3a506b988f1e0b80 /database/conn.go
downloadwhois-d25ec27fb1c3df175e1b98af1fdc26881d68a1ab.tar.gz
whois-d25ec27fb1c3df175e1b98af1fdc26881d68a1ab.zip
initial commit by simponic-infra
Diffstat (limited to 'database/conn.go')
-rw-r--r--database/conn.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/database/conn.go b/database/conn.go
new file mode 100644
index 0000000..be27586
--- /dev/null
+++ b/database/conn.go
@@ -0,0 +1,17 @@
+package database
+
+import (
+ "database/sql"
+ _ "github.com/mattn/go-sqlite3"
+ "log"
+)
+
+func MakeConn(databasePath *string) *sql.DB {
+ log.Println("opening database at", *databasePath, "with foreign keys enabled")
+ dbConn, err := sql.Open("sqlite3", *databasePath+"?_foreign_keys=on")
+ if err != nil {
+ panic(err)
+ }
+
+ return dbConn
+}