Skip to content

Commit

Permalink
add db.Execute
Browse files Browse the repository at this point in the history
  • Loading branch information
delaneyj committed Jul 3, 2024
1 parent f419860 commit 016fe53
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
version: "3"

vars:
VERSION: 0.2.8
VERSION: 0.2.9

interval: 200ms

Expand Down
10 changes: 10 additions & 0 deletions database.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ func NewDatabase(ctx context.Context, dbFilename string, migrations []string) (*
return db, nil
}

func (db *Database) Execute(ctx context.Context, query string, opts *sqlitex.ExecOptions) error {
conn, err := db.writePool.Take(ctx)
if err != nil {
return fmt.Errorf("failed to take write connection: %w", err)
}
defer db.writePool.Put(conn)

return sqlitex.Execute(conn, query, opts)
}

func (db *Database) Reset(ctx context.Context, shouldClear bool) (err error) {
if err := db.Close(); err != nil {
return fmt.Errorf("could not close database: %w", err)
Expand Down

0 comments on commit 016fe53

Please sign in to comment.