本文整理匯總了Golang中github.com/jmoiron/sqlx.Execer類的典型用法代碼示例。如果您正苦於以下問題:Golang Execer類的具體用法?Golang Execer怎麽用?Golang Execer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Execer類的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
}