Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append to an existing DB #55

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading