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-03 01:13:52 +03: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-03 08:45:15 +03:00
log.Panic(err)
}
defer stmt.Close()
_, err = stmt.Exec()
if err != nil {
log.Warnln(err)
}
}