本文整理汇总了Golang中github.com/jmoiron/sqlx.DB.NamedExec方法的典型用法代码示例。如果您正苦于以下问题:Golang DB.NamedExec方法的具体用法?Golang DB.NamedExec怎么用?Golang DB.NamedExec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jmoiron/sqlx.DB
的用法示例。
在下文中一共展示了DB.NamedExec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: postStaticdnsentry
// @Title postStaticdnsentries
// @Description enter a new staticdnsentries
// @Accept application/json
// @Param Body body Staticdnsentries true "Staticdnsentries object that should be added to the table"
// @Success 200 {object} output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/staticdnsentries [post]
func postStaticdnsentry(payload []byte, db *sqlx.DB) (interface{}, error) {
var v Staticdnsentries
err := json.Unmarshal(payload, &v)
if err != nil {
log.Println(err)
return nil, err
}
sqlString := "INSERT INTO staticdnsentries("
sqlString += "name"
sqlString += ",type"
sqlString += ",class"
sqlString += ",ttl"
sqlString += ",rdata"
sqlString += ",deliveryservice"
sqlString += ",cachegroup"
sqlString += ",created_at"
sqlString += ") VALUES ("
sqlString += ":name"
sqlString += ",:type"
sqlString += ",:class"
sqlString += ",:ttl"
sqlString += ",:rdata"
sqlString += ",:deliveryservice"
sqlString += ",:cachegroup"
sqlString += ",:created_at"
sqlString += ")"
result, err := db.NamedExec(sqlString, v)
if err != nil {
log.Println(err)
return nil, err
}
return result, err
}
示例2: postCachegroup
// @Title postCachegroup
// @Description enter a new cachegroup
// @Accept application/json
// @Param Body body Cachegroup true "Cachegroup object that should be added to the table"
// @Success 200 {object} output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/cachegroup [post]
func postCachegroup(payload []byte, db *sqlx.DB) (interface{}, error) {
var v Cachegroup
err := json.Unmarshal(payload, &v)
if err != nil {
log.Println(err)
}
sqlString := "INSERT INTO cachegroup("
sqlString += "name"
sqlString += ",short_name"
sqlString += ",latitude"
sqlString += ",longitude"
sqlString += ",parent_cachegroup"
sqlString += ",secondary_parent_cachegroup"
sqlString += ",type"
sqlString += ") VALUES ("
sqlString += ":name"
sqlString += ",:short_name"
sqlString += ",:latitude"
sqlString += ",:longitude"
sqlString += ",:parent_cachegroup"
sqlString += ",:secondary_parent_cachegroup"
sqlString += ",:type"
sqlString += ")"
result, err := db.NamedExec(sqlString, v)
if err != nil {
log.Println(err)
return nil, err
}
return result, err
}
示例3: putStaticdnsentry
// @Title putStaticdnsentry
// @Description modify an existing staticdnsentryentry
// @Accept application/json
// @Param id path int true "The row id"
// @Param Body body Staticdnsentry true "Staticdnsentry object that should be added to the table"
// @Success 200 {object} output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/staticdnsentry/{id} [put]
func putStaticdnsentry(id int, payload []byte, db *sqlx.DB) (interface{}, error) {
var v Staticdnsentry
err := json.Unmarshal(payload, &v)
v.Id = int64(id) // overwrite the id in the payload
if err != nil {
log.Println(err)
return nil, err
}
v.LastUpdated = time.Now()
sqlString := "UPDATE staticdnsentry SET "
sqlString += "host = :host"
sqlString += ",address = :address"
sqlString += ",type = :type"
sqlString += ",ttl = :ttl"
sqlString += ",deliveryservice = :deliveryservice"
sqlString += ",cachegroup = :cachegroup"
sqlString += ",last_updated = :last_updated"
sqlString += " WHERE id=:id"
result, err := db.NamedExec(sqlString, v)
if err != nil {
log.Println(err)
return nil, err
}
return result, err
}
示例4: putStaticdnsentry
// @Title putStaticdnsentries
// @Description modify an existing staticdnsentriesentry
// @Accept application/json
// @Param id path int true "The row id"
// @Param Body body Staticdnsentries true "Staticdnsentries object that should be added to the table"
// @Success 200 {object} output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/staticdnsentries/{id} [put]
func putStaticdnsentry(id int64, payload []byte, db *sqlx.DB) (interface{}, error) {
var arg Staticdnsentries
err := json.Unmarshal(payload, &arg)
arg.Id = id
if err != nil {
log.Println(err)
return nil, err
}
sqlString := "UPDATE staticdnsentries SET "
sqlString += "name = :name"
sqlString += ",type = :type"
sqlString += ",class = :class"
sqlString += ",ttl = :ttl"
sqlString += ",rdata = :rdata"
sqlString += ",deliveryservice = :deliveryservice"
sqlString += ",cachegroup = :cachegroup"
sqlString += ",created_at = :created_at"
sqlString += " WHERE id=:id"
result, err := db.NamedExec(sqlString, arg)
if err != nil {
log.Println(err)
return nil, err
}
return result, err
}
示例5: postUser
// @Title postUsers
// @Description enter a new users
// @Accept application/json
// @Param Body body Users true "Users object that should be added to the table"
// @Success 200 {object} output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/users [post]
func postUser(payload []byte, db *sqlx.DB) (interface{}, error) {
var v Users
err := json.Unmarshal(payload, &v)
if err != nil {
log.Println(err)
return nil, err
}
sqlString := "INSERT INTO users("
sqlString += "username"
sqlString += ",role"
sqlString += ",email"
sqlString += ",full_name"
sqlString += ",ssh_pub_key"
sqlString += ",local_password"
sqlString += ",created_at"
sqlString += ") VALUES ("
sqlString += ":username"
sqlString += ",:role"
sqlString += ",:email"
sqlString += ",:full_name"
sqlString += ",:ssh_pub_key"
sqlString += ",:local_password"
sqlString += ",:created_at"
sqlString += ")"
result, err := db.NamedExec(sqlString, v)
if err != nil {
log.Println(err)
return nil, err
}
return result, err
}
示例6: postFederationUser
// @Title postFederationUsers
// @Description enter a new federation_users
// @Accept application/json
// @Param Body body FederationUsers true "FederationUsers object that should be added to the table"
// @Success 200 {object} output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/federation_users [post]
func postFederationUser(payload []byte, db *sqlx.DB) (interface{}, error) {
var v FederationUsers
err := json.Unmarshal(payload, &v)
if err != nil {
log.Println(err)
return nil, err
}
sqlString := "INSERT INTO federation_users("
sqlString += "federation_id"
sqlString += ",username"
sqlString += ",role"
sqlString += ",created_at"
sqlString += ") VALUES ("
sqlString += ":federation_id"
sqlString += ",:username"
sqlString += ",:role"
sqlString += ",:created_at"
sqlString += ")"
result, err := db.NamedExec(sqlString, v)
if err != nil {
log.Println(err)
return nil, err
}
return result, err
}
示例7: putExtension
// @Title putExtensions
// @Description modify an existing extensionsentry
// @Accept application/json
// @Param id path int true "The row id"
// @Param Body body Extensions true "Extensions object that should be added to the table"
// @Success 200 {object} output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/extensions/{id} [put]
func putExtension(name string, payload []byte, db *sqlx.DB) (interface{}, error) {
var arg Extensions
err := json.Unmarshal(payload, &arg)
arg.Name = name
if err != nil {
log.Println(err)
return nil, err
}
sqlString := "UPDATE extensions SET "
sqlString += "name = :name"
sqlString += ",short_name = :short_name"
sqlString += ",description = :description"
sqlString += ",version = :version"
sqlString += ",info_url = :info_url"
sqlString += ",script_file = :script_file"
sqlString += ",active = :active"
sqlString += ",additional_config_json = :additional_config_json"
sqlString += ",type = :type"
sqlString += ",created_at = :created_at"
sqlString += " WHERE name=:name"
result, err := db.NamedExec(sqlString, arg)
if err != nil {
log.Println(err)
return nil, err
}
return result, err
}
示例8: postStatsSummary
// @Title postStatsSummary
// @Description enter a new stats_summary
// @Accept application/json
// @Param Body body StatsSummary true "StatsSummary object that should be added to the table"
// @Success 200 {object} output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/stats_summary [post]
func postStatsSummary(payload []byte, db *sqlx.DB) (interface{}, error) {
var v StatsSummary
err := json.Unmarshal(payload, &v)
if err != nil {
log.Println(err)
}
sqlString := "INSERT INTO stats_summary("
sqlString += "cdn_name"
sqlString += ",deliveryservice_name"
sqlString += ",stat_name"
sqlString += ",stat_value"
sqlString += ",summary_time"
sqlString += ",stat_date"
sqlString += ") VALUES ("
sqlString += ":cdn_name"
sqlString += ",:deliveryservice_name"
sqlString += ",:stat_name"
sqlString += ",:stat_value"
sqlString += ",:summary_time"
sqlString += ",:stat_date"
sqlString += ")"
result, err := db.NamedExec(sqlString, v)
if err != nil {
log.Println(err)
return nil, err
}
return result, err
}
示例9: postJobResult
// @Title postJobResult
// @Description enter a new job_result
// @Accept application/json
// @Param Body body JobResult true "JobResult object that should be added to the table"
// @Success 200 {object} output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/job_result [post]
func postJobResult(payload []byte, db *sqlx.DB) (interface{}, error) {
var v JobResult
err := json.Unmarshal(payload, &v)
if err != nil {
log.Println(err)
return nil, err
}
sqlString := "INSERT INTO job_result("
sqlString += "job"
sqlString += ",job_agent"
sqlString += ",result"
sqlString += ",description"
sqlString += ") VALUES ("
sqlString += ":job"
sqlString += ",:job_agent"
sqlString += ",:result"
sqlString += ",:description"
sqlString += ")"
result, err := db.NamedExec(sqlString, v)
if err != nil {
log.Println(err)
return nil, err
}
return result, err
}
示例10: putToExtension
// @Title putToExtension
// @Description modify an existing to_extensionentry
// @Accept application/json
// @Param id path int true "The row id"
// @Param Body body ToExtension true "ToExtension object that should be added to the table"
// @Success 200 {object} output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/to_extension/{id} [put]
func putToExtension(id int, payload []byte, db *sqlx.DB) (interface{}, error) {
var v ToExtension
err := json.Unmarshal(payload, &v)
v.Id = int64(id) // overwrite the id in the payload
if err != nil {
log.Println(err)
return nil, err
}
v.LastUpdated = time.Now()
sqlString := "UPDATE to_extension SET "
sqlString += "name = :name"
sqlString += ",version = :version"
sqlString += ",info_url = :info_url"
sqlString += ",script_file = :script_file"
sqlString += ",isactive = :isactive"
sqlString += ",additional_config_json = :additional_config_json"
sqlString += ",description = :description"
sqlString += ",servercheck_short_name = :servercheck_short_name"
sqlString += ",servercheck_column_name = :servercheck_column_name"
sqlString += ",type = :type"
sqlString += ",last_updated = :last_updated"
sqlString += " WHERE id=:id"
result, err := db.NamedExec(sqlString, v)
if err != nil {
log.Println(err)
return nil, err
}
return result, err
}
示例11: putJob
// @Title putJob
// @Description modify an existing jobentry
// @Accept application/json
// @Param id path int true "The row id"
// @Param Body body Job true "Job object that should be added to the table"
// @Success 200 {object} output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/job/{id} [put]
func putJob(id int, payload []byte, db *sqlx.DB) (interface{}, error) {
var v Job
err := json.Unmarshal(payload, &v)
v.Id = int64(id) // overwrite the id in the payload
if err != nil {
log.Println(err)
return nil, err
}
v.LastUpdated = time.Now()
sqlString := "UPDATE job SET "
sqlString += "job_agent = :job_agent"
sqlString += ",object_type = :object_type"
sqlString += ",object_name = :object_name"
sqlString += ",keyword = :keyword"
sqlString += ",parameters = :parameters"
sqlString += ",asset_url = :asset_url"
sqlString += ",asset_type = :asset_type"
sqlString += ",status = :status"
sqlString += ",start_time = :start_time"
sqlString += ",entered_time = :entered_time"
sqlString += ",tm_user = :tm_user"
sqlString += ",last_updated = :last_updated"
sqlString += ",deliveryservice = :deliveryservice"
sqlString += " WHERE id=:id"
result, err := db.NamedExec(sqlString, v)
if err != nil {
log.Println(err)
return nil, err
}
return result, err
}
示例12: putCachegroup
// @Title putCachegroup
// @Description modify an existing cachegroupentry
// @Accept application/json
// @Param id path int true "The row id"
// @Param Body body Cachegroup true "Cachegroup object that should be added to the table"
// @Success 200 {object} output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/cachegroup/{id} [put]
func putCachegroup(id int, payload []byte, db *sqlx.DB) (interface{}, error) {
var v Cachegroup
err := json.Unmarshal(payload, &v)
v.Id = int64(id) // overwrite the id in the payload
if err != nil {
log.Println(err)
return nil, err
}
v.LastUpdated = time.Now()
sqlString := "UPDATE cachegroup SET "
sqlString += "name = :name"
sqlString += ",short_name = :short_name"
sqlString += ",latitude = :latitude"
sqlString += ",longitude = :longitude"
sqlString += ",parent_cachegroup = :parent_cachegroup"
sqlString += ",secondary_parent_cachegroup = :secondary_parent_cachegroup"
sqlString += ",type = :type"
sqlString += ",last_updated = :last_updated"
sqlString += " WHERE id=:id"
result, err := db.NamedExec(sqlString, v)
if err != nil {
log.Println(err)
return nil, err
}
return result, err
}
示例13: postFederation
// @Title postFederations
// @Description enter a new federations
// @Accept application/json
// @Param Body body Federations true "Federations object that should be added to the table"
// @Success 200 {object} output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/federations [post]
func postFederation(payload []byte, db *sqlx.DB) (interface{}, error) {
var v Federations
err := json.Unmarshal(payload, &v)
if err != nil {
log.Println(err)
return nil, err
}
sqlString := "INSERT INTO federations("
sqlString += "cname"
sqlString += ",description"
sqlString += ",ttl"
sqlString += ",created_at"
sqlString += ") VALUES ("
sqlString += ":cname"
sqlString += ",:description"
sqlString += ",:ttl"
sqlString += ",:created_at"
sqlString += ")"
result, err := db.NamedExec(sqlString, v)
if err != nil {
log.Println(err)
return nil, err
}
return result, err
}
示例14: putDeliveryservice
// @Title putDeliveryservice
// @Description modify an existing deliveryserviceentry
// @Accept application/json
// @Param id path int true "The row id"
// @Param Body body Deliveryservice true "Deliveryservice object that should be added to the table"
// @Success 200 {object} output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/deliveryservice/{id} [put]
func putDeliveryservice(id int, payload []byte, db *sqlx.DB) (interface{}, error) {
var v Deliveryservice
err := json.Unmarshal(payload, &v)
v.Id = int64(id) // overwrite the id in the payload
if err != nil {
log.Println(err)
return nil, err
}
v.LastUpdated = time.Now()
sqlString := "UPDATE deliveryservice SET "
sqlString += "xml_id = :xml_id"
sqlString += ",active = :active"
sqlString += ",dscp = :dscp"
sqlString += ",signed = :signed"
sqlString += ",qstring_ignore = :qstring_ignore"
sqlString += ",geo_limit = :geo_limit"
sqlString += ",http_bypass_fqdn = :http_bypass_fqdn"
sqlString += ",dns_bypass_ip = :dns_bypass_ip"
sqlString += ",dns_bypass_ip6 = :dns_bypass_ip6"
sqlString += ",dns_bypass_ttl = :dns_bypass_ttl"
sqlString += ",org_server_fqdn = :org_server_fqdn"
sqlString += ",type = :type"
sqlString += ",profile = :profile"
sqlString += ",cdn = :cdn"
sqlString += ",ccr_dns_ttl = :ccr_dns_ttl"
sqlString += ",global_max_mbps = :global_max_mbps"
sqlString += ",global_max_tps = :global_max_tps"
sqlString += ",long_desc = :long_desc"
sqlString += ",long_desc_1 = :long_desc_1"
sqlString += ",long_desc_2 = :long_desc_2"
sqlString += ",max_dns_answers = :max_dns_answers"
sqlString += ",info_url = :info_url"
sqlString += ",miss_lat = :miss_lat"
sqlString += ",miss_long = :miss_long"
sqlString += ",check_path = :check_path"
sqlString += ",last_updated = :last_updated"
sqlString += ",protocol = :protocol"
sqlString += ",ssl_key_version = :ssl_key_version"
sqlString += ",ipv6_routing_enabled = :ipv6_routing_enabled"
sqlString += ",range_request_handling = :range_request_handling"
sqlString += ",edge_header_rewrite = :edge_header_rewrite"
sqlString += ",origin_shield = :origin_shield"
sqlString += ",mid_header_rewrite = :mid_header_rewrite"
sqlString += ",regex_remap = :regex_remap"
sqlString += ",cacheurl = :cacheurl"
sqlString += ",remap_text = :remap_text"
sqlString += ",multi_site_origin = :multi_site_origin"
sqlString += ",display_name = :display_name"
sqlString += ",tr_response_headers = :tr_response_headers"
sqlString += ",initial_dispersion = :initial_dispersion"
sqlString += ",dns_bypass_cname = :dns_bypass_cname"
sqlString += ",tr_request_headers = :tr_request_headers"
sqlString += " WHERE id=:id"
result, err := db.NamedExec(sqlString, v)
if err != nil {
log.Println(err)
return nil, err
}
return result, err
}
示例15: ActionMove
func ActionMove(db *sqlx.DB, params ActionParams) (err error) {
fmt.Println(params)
fmt.Println("Move", params.Oldslotid, "to", params.Slotid, "where charges =", params.Oldquantity, ",id =", params.Itemid)
result, err := db.NamedExec(`UPDATE inventory SET
itemid = :itemid,
slotid = :slotid,
charges = :quantity,
charid = :charid
WHERE slotid = :oldslotid AND
itemid = :itemid AND
charid = :charid
`, params)
if err != nil {
return
}
count, err := result.RowsAffected()
if err != nil {
return
}
if count < 1 {
err = fmt.Errorf("No rows affected.")
}
return
}