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