Skip to content

Commit

Permalink
Append to an existing DB
Browse files Browse the repository at this point in the history
(cherry picked from commit 084a5e4)
  • Loading branch information
fillson-shady committed Sep 3, 2024
1 parent ac6e5cb commit 34e720e
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions coyote.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,7 @@ func main() {
var insert *sql.Stmt
if ctx.IsSet("store") {
filename := ctx.String("store")
file, err := os.Create(filename)
if err != nil {
log.Fatal(err)
}
file.Close()
db, err = sql.Open("sqlite", filename+"?_txlock=exclusive")
db, err = sql.Open("sqlite", filename+"?_txlock=exclusive&mode=rwc")
if err != nil {
log.Fatal(err)
}
Expand All @@ -249,7 +244,7 @@ func main() {
log.Printf("💔 Closing database connection")
}()

create, err := db.Prepare(`CREATE TABLE event
create, err := db.Prepare(`CREATE TABLE IF NOT EXISTS event
(
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"timestamp" TIMESTAMP DEFAULT (DATETIME(CURRENT_TIMESTAMP, 'localtime')),
Expand Down

0 comments on commit 34e720e

Please sign in to comment.