本文整理汇总了Golang中github.com/jackc/pgx.QueryArgs函数的典型用法代码示例。如果您正苦于以下问题:Golang QueryArgs函数的具体用法?Golang QueryArgs怎么用?Golang QueryArgs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QueryArgs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: UpdateIPTypes
func UpdateIPTypes(db Queryer,
id int32,
row *IPTypes,
) error {
sets := make([]string, 0, 3)
args := pgx.QueryArgs(make([]interface{}, 0, 3))
row.ID.addUpdate(`id`, &sets, &args)
row.IPInet.addUpdate(`ip_inet`, &sets, &args)
row.IPCidr.addUpdate(`ip_cidr`, &sets, &args)
if len(sets) == 0 {
return nil
}
sql := `update "ip_types" set ` + strings.Join(sets, ", ") + ` where ` + `"id"=` + args.Append(id)
psName := preparedName("pgxdataUpdateIPTypes", sql)
commandTag, err := prepareExec(db, psName, sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return ErrNotFound
}
return nil
}
开发者ID:jackc,项目名称:pgxdata,代码行数:28,代码来源:pgxdata_i_p_types.go
示例2: UpdateFeed
func UpdateFeed(db Queryer,
id int32,
row *Feed,
) error {
sets := make([]string, 0, 9)
args := pgx.QueryArgs(make([]interface{}, 0, 9))
row.ID.addUpdate(`id`, &sets, &args)
row.Name.addUpdate(`name`, &sets, &args)
row.URL.addUpdate(`url`, &sets, &args)
row.LastFetchTime.addUpdate(`last_fetch_time`, &sets, &args)
row.ETag.addUpdate(`etag`, &sets, &args)
row.LastFailure.addUpdate(`last_failure`, &sets, &args)
row.LastFailureTime.addUpdate(`last_failure_time`, &sets, &args)
row.FailureCount.addUpdate(`failure_count`, &sets, &args)
row.CreationTime.addUpdate(`creation_time`, &sets, &args)
if len(sets) == 0 {
return nil
}
sql := `update "feeds" set ` + strings.Join(sets, ", ") + ` where ` + `"id"=` + args.Append(id)
psName := preparedName("pgxdataUpdateFeed", sql)
commandTag, err := prepareExec(db, psName, sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return ErrNotFound
}
return nil
}
开发者ID:jackc,项目名称:tpr,代码行数:34,代码来源:pgxdata_feed.go
示例3: UpdateWidget
func UpdateWidget(db Queryer,
id int64,
row *Widget,
) error {
sets := make([]string, 0, 3)
args := pgx.QueryArgs(make([]interface{}, 0, 3))
row.ID.addUpdate(`id`, &sets, &args)
row.Name.addUpdate(`name`, &sets, &args)
row.Weight.addUpdate(`weight`, &sets, &args)
if len(sets) == 0 {
return nil
}
sql := `update "widget" set ` + strings.Join(sets, ", ") + ` where ` + `"id"=` + args.Append(id)
commandTag, err := db.Exec(sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return pgx.ErrNoRows
}
return nil
}
开发者ID:sguzwf,项目名称:pgxdata,代码行数:26,代码来源:widget.go
示例4: UpdateRenamedFieldCustomer
func UpdateRenamedFieldCustomer(db Queryer,
id int32,
row *RenamedFieldCustomer,
) error {
sets := make([]string, 0, 5)
args := pgx.QueryArgs(make([]interface{}, 0, 5))
row.ID.addUpdate(`id`, &sets, &args)
row.FName.addUpdate(`first_name`, &sets, &args)
row.LastName.addUpdate(`last_name`, &sets, &args)
row.BirthDate.addUpdate(`birth_date`, &sets, &args)
row.CreationTime.addUpdate(`creation_time`, &sets, &args)
if len(sets) == 0 {
return nil
}
sql := `update "customer" set ` + strings.Join(sets, ", ") + ` where ` + `"id"=` + args.Append(id)
psName := preparedName("pgxdataUpdateRenamedFieldCustomer", sql)
commandTag, err := prepareExec(db, psName, sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return ErrNotFound
}
return nil
}
开发者ID:jackc,项目名称:pgxdata,代码行数:30,代码来源:pgxdata_renamed_field_customer.go
示例5: UpdateBlob
func UpdateBlob(db Queryer,
id int32,
row *Blob,
) error {
sets := make([]string, 0, 2)
args := pgx.QueryArgs(make([]interface{}, 0, 2))
row.ID.addUpdate(`id`, &sets, &args)
row.Payload.addUpdate(`payload`, &sets, &args)
if len(sets) == 0 {
return nil
}
sql := `update "blob" set ` + strings.Join(sets, ", ") + ` where ` + `"id"=` + args.Append(id)
psName := preparedName("pgxdataUpdateBlob", sql)
commandTag, err := prepareExec(db, psName, sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return ErrNotFound
}
return nil
}
开发者ID:jackc,项目名称:pgxdata,代码行数:27,代码来源:pgxdata_blob.go
示例6: UpdateSession
func UpdateSession(db Queryer,
id []byte,
row *Session,
) error {
sets := make([]string, 0, 3)
args := pgx.QueryArgs(make([]interface{}, 0, 3))
row.ID.addUpdate(`id`, &sets, &args)
row.UserID.addUpdate(`user_id`, &sets, &args)
row.StartTime.addUpdate(`start_time`, &sets, &args)
if len(sets) == 0 {
return nil
}
sql := `update "sessions" set ` + strings.Join(sets, ", ") + ` where ` + `"id"=` + args.Append(id)
psName := preparedName("pgxdataUpdateSession", sql)
commandTag, err := prepareExec(db, psName, sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return ErrNotFound
}
return nil
}
开发者ID:jackc,项目名称:tpr,代码行数:28,代码来源:pgxdata_session.go
示例7: UpdatePasswordReset
func UpdatePasswordReset(db Queryer,
token string,
row *PasswordReset,
) error {
sets := make([]string, 0, 7)
args := pgx.QueryArgs(make([]interface{}, 0, 7))
row.Token.addUpdate(`token`, &sets, &args)
row.Email.addUpdate(`email`, &sets, &args)
row.RequestIP.addUpdate(`request_ip`, &sets, &args)
row.RequestTime.addUpdate(`request_time`, &sets, &args)
row.UserID.addUpdate(`user_id`, &sets, &args)
row.CompletionIP.addUpdate(`completion_ip`, &sets, &args)
row.CompletionTime.addUpdate(`completion_time`, &sets, &args)
if len(sets) == 0 {
return nil
}
sql := `update "password_resets" set ` + strings.Join(sets, ", ") + ` where ` + `"token"=` + args.Append(token)
psName := preparedName("pgxdataUpdatePasswordReset", sql)
commandTag, err := prepareExec(db, psName, sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return ErrNotFound
}
return nil
}
开发者ID:jackc,项目名称:tpr,代码行数:32,代码来源:pgxdata_password_reset.go
示例8: UpdateSemester
func UpdateSemester(db Queryer,
year int16,
season string,
row *Semester,
) error {
sets := make([]string, 0, 3)
args := pgx.QueryArgs(make([]interface{}, 0, 3))
row.Year.addUpdate(`year`, &sets, &args)
row.Season.addUpdate(`season`, &sets, &args)
row.Description.addUpdate(`description`, &sets, &args)
if len(sets) == 0 {
return nil
}
sql := `update "semester" set ` + strings.Join(sets, ", ") + ` where ` + `"year"=` + args.Append(year) + ` and "season"=` + args.Append(season)
commandTag, err := db.Exec(sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return pgx.ErrNoRows
}
return nil
}
开发者ID:sguzwf,项目名称:pgxdata,代码行数:27,代码来源:semester.go
示例9: UpdatePart
func UpdatePart(db Queryer,
code string,
row *Part,
) error {
sets := make([]string, 0, 2)
args := pgx.QueryArgs(make([]interface{}, 0, 2))
row.Code.addUpdate(`code`, &sets, &args)
row.Description.addUpdate(`description`, &sets, &args)
if len(sets) == 0 {
return nil
}
sql := `update "part" set ` + strings.Join(sets, ", ") + ` where ` + `"code"=` + args.Append(code)
commandTag, err := db.Exec(sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return pgx.ErrNoRows
}
return nil
}
开发者ID:sguzwf,项目名称:pgxdata,代码行数:25,代码来源:part.go
示例10: UpdateCustomer
func UpdateCustomer(db Queryer,
id int32,
row *Customer,
) error {
sets := make([]string, 0, 5)
args := pgx.QueryArgs(make([]interface{}, 0, 5))
row.ID.addUpdate(`id`, &sets, &args)
row.FirstName.addUpdate(`first_name`, &sets, &args)
row.LastName.addUpdate(`last_name`, &sets, &args)
row.BirthDate.addUpdate(`birth_date`, &sets, &args)
row.CreationTime.addUpdate(`creation_time`, &sets, &args)
if len(sets) == 0 {
return nil
}
sql := `update "customer" set ` + strings.Join(sets, ", ") + ` where ` + `"id"=` + args.Append(id)
commandTag, err := db.Exec(sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return pgx.ErrNoRows
}
return nil
}
开发者ID:sguzwf,项目名称:pgxdata,代码行数:28,代码来源:customer.go
示例11: UpdateUser
func UpdateUser(db Queryer,
id int32,
row *User,
) error {
sets := make([]string, 0, 5)
args := pgx.QueryArgs(make([]interface{}, 0, 5))
row.ID.addUpdate(`id`, &sets, &args)
row.Name.addUpdate(`name`, &sets, &args)
row.PasswordDigest.addUpdate(`password_digest`, &sets, &args)
row.PasswordSalt.addUpdate(`password_salt`, &sets, &args)
row.Email.addUpdate(`email`, &sets, &args)
if len(sets) == 0 {
return nil
}
sql := `update "users" set ` + strings.Join(sets, ", ") + ` where ` + `"id"=` + args.Append(id)
psName := preparedName("pgxdataUpdateUser", sql)
commandTag, err := prepareExec(db, psName, sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return ErrNotFound
}
return nil
}
开发者ID:jackc,项目名称:tpr,代码行数:30,代码来源:pgxdata_user.go
示例12: BenchmarkQueryArgs
func BenchmarkQueryArgs(b *testing.B) {
for i := 0; i < b.N; i++ {
qa := pgx.QueryArgs(make([]interface{}, 0, 16))
qa.Append("foo1")
qa.Append("foo2")
qa.Append("foo3")
qa.Append("foo4")
qa.Append("foo5")
qa.Append("foo6")
qa.Append("foo7")
qa.Append("foo8")
qa.Append("foo9")
qa.Append("foo10")
}
}
开发者ID:segmentio,项目名称:pgx,代码行数:15,代码来源:sql_test.go
示例13: InsertPart
func InsertPart(db Queryer, row *Part) error {
args := pgx.QueryArgs(make([]interface{}, 0, 2))
var columns, values []string
row.Code.addInsert(`code`, &columns, &values, &args)
row.Description.addInsert(`description`, &columns, &values, &args)
sql := `insert into "part"(` + strings.Join(columns, ", ") + `)
values(` + strings.Join(values, ",") + `)
returning "code"
`
return db.QueryRow(sql, args...).Scan(&row.Code)
}
开发者ID:sguzwf,项目名称:pgxdata,代码行数:15,代码来源:part.go
示例14: DeletePasswordReset
func DeletePasswordReset(db Queryer,
token string,
) error {
args := pgx.QueryArgs(make([]interface{}, 0, 1))
sql := `delete from "password_resets" where ` + `"token"=` + args.Append(token)
commandTag, err := prepareExec(db, "pgxdataDeletePasswordReset", sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return ErrNotFound
}
return nil
}
开发者ID:jackc,项目名称:tpr,代码行数:16,代码来源:pgxdata_password_reset.go
示例15: DeleteBlob
func DeleteBlob(db Queryer,
id int32,
) error {
args := pgx.QueryArgs(make([]interface{}, 0, 1))
sql := `delete from "blob" where ` + `"id"=` + args.Append(id)
commandTag, err := prepareExec(db, "pgxdataDeleteBlob", sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return ErrNotFound
}
return nil
}
开发者ID:jackc,项目名称:pgxdata,代码行数:16,代码来源:pgxdata_blob.go
示例16: InsertWidget
func InsertWidget(db Queryer, row *Widget) error {
args := pgx.QueryArgs(make([]interface{}, 0, 3))
var columns, values []string
row.ID.addInsert(`id`, &columns, &values, &args)
row.Name.addInsert(`name`, &columns, &values, &args)
row.Weight.addInsert(`weight`, &columns, &values, &args)
sql := `insert into "widget"(` + strings.Join(columns, ", ") + `)
values(` + strings.Join(values, ",") + `)
returning "id"
`
return db.QueryRow(sql, args...).Scan(&row.ID)
}
开发者ID:sguzwf,项目名称:pgxdata,代码行数:16,代码来源:widget.go
示例17: DeletePart
func DeletePart(db Queryer,
code string,
) error {
args := pgx.QueryArgs(make([]interface{}, 0, 1))
sql := `delete from "part" where ` + `"code"=` + args.Append(code)
commandTag, err := db.Exec(sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return pgx.ErrNoRows
}
return nil
}
开发者ID:sguzwf,项目名称:pgxdata,代码行数:16,代码来源:part.go
示例18: DeleteWidget
func DeleteWidget(db Queryer,
id int64,
) error {
args := pgx.QueryArgs(make([]interface{}, 0, 1))
sql := `delete from "widget" where ` + `"id"=` + args.Append(id)
commandTag, err := db.Exec(sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return pgx.ErrNoRows
}
return nil
}
开发者ID:sguzwf,项目名称:pgxdata,代码行数:16,代码来源:widget.go
示例19: InsertSemester
func InsertSemester(db Queryer, row *Semester) error {
args := pgx.QueryArgs(make([]interface{}, 0, 3))
var columns, values []string
row.Year.addInsert(`year`, &columns, &values, &args)
row.Season.addInsert(`season`, &columns, &values, &args)
row.Description.addInsert(`description`, &columns, &values, &args)
sql := `insert into "semester"(` + strings.Join(columns, ", ") + `)
values(` + strings.Join(values, ",") + `)
returning "year", "season"
`
return db.QueryRow(sql, args...).Scan(&row.Year, &row.Season)
}
开发者ID:sguzwf,项目名称:pgxdata,代码行数:16,代码来源:semester.go
示例20: DeleteSemester
func DeleteSemester(db Queryer,
year int16,
season string,
) error {
args := pgx.QueryArgs(make([]interface{}, 0, 2))
sql := `delete from "semester" where ` + `"year"=` + args.Append(year) + ` and "season"=` + args.Append(season)
commandTag, err := db.Exec(sql, args...)
if err != nil {
return err
}
if commandTag.RowsAffected() != 1 {
return pgx.ErrNoRows
}
return nil
}
开发者ID:sguzwf,项目名称:pgxdata,代码行数:17,代码来源:semester.go
注:本文中的github.com/jackc/pgx.QueryArgs函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论