0
owncast/utils/db.go

21 lines
337 B
Go
Raw Permalink Normal View History

package utils
import (
"database/sql"
log "github.com/sirupsen/logrus"
)
2022-08-02 15:13:52 -07:00
// MustExec will execute a SQL statement on a provided database instance.
func MustExec(s string, db *sql.DB) {
stmt, err := db.Prepare(s)
if err != nil {
2022-08-02 22:45:15 -07:00
log.Panic(err)
}
defer stmt.Close()
_, err = stmt.Exec()
if err != nil {
log.Warnln(err)
}
}