本文整理汇总了Golang中github.com/jmoiron/sqlx.Execer.Exec方法的典型用法代码示例。如果您正苦于以下问题:Golang Execer.Exec方法的具体用法?Golang Execer.Exec怎么用?Golang Execer.Exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jmoiron/sqlx.Execer
的用法示例。
在下文中一共展示了Execer.Exec方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: execl
// add back execl because it's been removed from sqlx for a long time
func execl(db sqlx.Execer, q string, args ...interface{}) sql.Result {
res, err := db.Exec(q, args...)
if err != nil {
log.Printf("Error executing %s %#v: %s", q, args, err)
}
return res
}
示例2: Execf
func Execf(e sqlx.Execer, query string, args ...interface{}) (sql.Result, error) {
res, err := e.Exec(query, args...)
if err != nil {
log.Fatalln(query, res, err)
}
return res, err
}
示例3: MultiExec
// MultiExec is a helper function for running multiple queries.
func MultiExec(e sqlx.Execer, query string) {
stmts := strings.Split(query, ";\n")
if len(strings.Trim(stmts[len(stmts)-1], " \n\t\r")) == 0 {
stmts = stmts[:len(stmts)-1]
}
for _, s := range stmts {
_, err := e.Exec(s)
if err != nil {
fmt.Println(err, s)
}
}
}
示例4: MultiExec
func MultiExec(e sqlx.Execer, query string) error {
stmts := strings.Split(query, ";\n")
if len(strings.Trim(stmts[len(stmts)-1], " \n\t\r")) == 0 {
stmts = stmts[:len(stmts)-1]
}
for _, s := range stmts {
if _, err := e.Exec(s); err != nil {
return err
}
}
return nil
}
示例5: DestroyAuthorizationWithCode
func DestroyAuthorizationWithCode(e sqlx.Execer, code string) error {
const (
Q = `DELETE FROM authorizations WHERE code = $1;`
)
_, err := e.Exec(Q, code)
if err == sql.ErrNoRows {
return nil
}
if err != nil {
return err
}
return nil
}
示例6: DestroyAccessTokenWithRefreshToken
func DestroyAccessTokenWithRefreshToken(e sqlx.Execer, token string) error {
const (
Q = `DELETE FROM access_tokens WHERE refresh_token = $1;`
)
_, err := e.Exec(Q, token)
if err == sql.ErrNoRows {
return nil
}
if err != nil {
return err
}
return nil
}