當前位置: 首頁>>代碼示例>>Golang>>正文


Golang sqlx.Execer類代碼示例

本文整理匯總了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
}
開發者ID:gale320,項目名稱:gowiki,代碼行數:8,代碼來源:gowiki.go

示例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
}
開發者ID:cmars,項目名稱:hockeypuck,代碼行數:7,代碼來源:db.go

示例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)
		}
	}
}
開發者ID:K4orta,項目名稱:tunnel-speed-api,代碼行數:13,代碼來源:utils.go

示例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
}
開發者ID:simonz05,項目名稱:database,代碼行數:14,代碼來源:schema.go

示例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
}
開發者ID:rogeriomarques,項目名稱:oapx,代碼行數:15,代碼來源:authorization.go

示例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
}
開發者ID:rogeriomarques,項目名稱:oapx,代碼行數:15,代碼來源:access_token.go


注:本文中的github.com/jmoiron/sqlx.Execer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。