• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang sqlstruct.Columns函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/kisielk/sqlstruct.Columns函数的典型用法代码示例。如果您正苦于以下问题:Golang Columns函数的具体用法?Golang Columns怎么用?Golang Columns使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Columns函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: GetOCSP

// GetOCSP retrieves a certdb.OCSPRecord from db by serial.
func (d *Accessor) GetOCSP(serial, aki string) (ors []certdb.OCSPRecord, err error) {
	err = d.checkDB()
	if err != nil {
		return nil, err
	}

	err = d.db.Select(&ors, fmt.Sprintf(d.db.Rebind(selectOCSPSQL), sqlstruct.Columns(certdb.OCSPRecord{})), serial, aki)
	if err != nil {
		return nil, wrapSQLError(err)
	}

	return ors, nil
}
开发者ID:constabulary,项目名称:docker-depfile-example,代码行数:14,代码来源:database_accessor.go


示例2: FetchBot

//Public Methods
func FetchBot(id string) (Bot, error) {
	rows, err := config.DB.Query(fmt.Sprintf("SELECT %s FROM bots WHERE group_id = $1", sqlstruct.Columns(Bot{})), id)
	if err != nil {
		return Bot{}, err
	}
	defer rows.Close()

	rows.Next()
	var bot Bot
	err = sqlstruct.Scan(&bot, rows)

	return bot, err
}
开发者ID:NelsonLeDuc,项目名称:CalmanBot,代码行数:14,代码来源:repo.go


示例3: GetUnexpiredOCSPs

// GetUnexpiredOCSPs retrieves all unexpired certdb.OCSPRecord from db.
func (d *Accessor) GetUnexpiredOCSPs() (ors []certdb.OCSPRecord, err error) {
	err = d.checkDB()
	if err != nil {
		return nil, err
	}

	err = d.db.Select(&ors, fmt.Sprintf(d.db.Rebind(selectAllUnexpiredOCSPSQL), sqlstruct.Columns(certdb.OCSPRecord{})))
	if err != nil {
		return nil, wrapSQLError(err)
	}

	return ors, nil
}
开发者ID:constabulary,项目名称:docker-depfile-example,代码行数:14,代码来源:database_accessor.go


示例4: GetUnexpiredCertificates

// GetUnexpiredCertificates gets all unexpired certificate from db.
func (d *Accessor) GetUnexpiredCertificates() (crs []certdb.CertificateRecord, err error) {
	err = d.checkDB()
	if err != nil {
		return nil, err
	}

	err = d.db.Select(&crs, fmt.Sprintf(d.db.Rebind(selectAllUnexpiredSQL), sqlstruct.Columns(certdb.CertificateRecord{})))
	if err != nil {
		return nil, wrapSQLError(err)
	}

	return crs, nil
}
开发者ID:constabulary,项目名称:docker-depfile-example,代码行数:14,代码来源:database_accessor.go


示例5: GetCertificate

// GetCertificate gets a CertificateRecord indexed by serial.
func GetCertificate(db *sql.DB, serial string) (*CertificateRecord, error) {
	cr := new(CertificateRecord)
	rows, err := db.Query(fmt.Sprintf(selectSQL, sqlstruct.Columns(*cr)), serial)
	if err != nil {
		return nil, wrapCertStoreError(err)
	}
	defer rows.Close()

	if rows.Next() {
		return cr, wrapCertStoreError(sqlstruct.Scan(cr, rows))
	}
	return nil, nil
}
开发者ID:jamesbjackson,项目名称:cfssl,代码行数:14,代码来源:certdb.go


示例6: GetCertificate

// GetCertificate gets a certdb.CertificateRecord indexed by serial.
func (d *Accessor) GetCertificate(serial, aki string) (crs []certdb.CertificateRecord, err error) {
	err = d.checkDB()
	if err != nil {
		return nil, err
	}

	err = d.db.Select(&crs, fmt.Sprintf(d.db.Rebind(selectSQL), sqlstruct.Columns(certdb.CertificateRecord{})), serial, aki)
	if err != nil {
		return nil, wrapSQLError(err)
	}

	return crs, nil
}
开发者ID:constabulary,项目名称:docker-depfile-example,代码行数:14,代码来源:database_accessor.go


示例7: GetOCSP

// GetOCSP retrieves a OCSPRecord from db by serial.
func GetOCSP(db *sql.DB, serial string) (rr *OCSPRecord, err error) {
	rr = new(OCSPRecord)
	rows, err := db.Query(fmt.Sprintf(selectOCSPSQL, sqlstruct.Columns(*rr)), serial)
	if err != nil {
		return nil, wrapCertStoreError(err)
	}
	defer rows.Close()

	if rows.Next() {
		return rr, sqlstruct.Scan(rr, rows)
	}
	return nil, nil
}
开发者ID:jamesbjackson,项目名称:cfssl,代码行数:14,代码来源:certdb.go


示例8: GetOCSP

// GetOCSP retrieves a certdb.OCSPRecord from db by serial.
func (d *Accessor) GetOCSP(serial string) (rr *certdb.OCSPRecord, err error) {
	err = d.checkDB()
	if err != nil {
		return nil, err
	}

	rr = new(certdb.OCSPRecord)
	rows, err := d.db.Query(fmt.Sprintf(selectOCSPSQL, sqlstruct.Columns(*rr)), serial)
	if err != nil {
		return nil, wrapSQLError(err)
	}
	defer rows.Close()

	if rows.Next() {
		return rr, sqlstruct.Scan(rr, rows)
	}
	return nil, nil
}
开发者ID:mclem,项目名称:cfssl,代码行数:19,代码来源:database_accessor.go


示例9: GetCertificate

// GetCertificate gets a certdb.CertificateRecord indexed by serial.
func (d *Accessor) GetCertificate(serial string) (*certdb.CertificateRecord, error) {
	err := d.checkDB()
	if err != nil {
		return nil, err
	}

	cr := new(certdb.CertificateRecord)
	rows, err := d.db.Query(fmt.Sprintf(selectSQL, sqlstruct.Columns(*cr)), serial)
	if err != nil {
		return nil, wrapSQLError(err)
	}
	defer rows.Close()

	if rows.Next() {
		return cr, wrapSQLError(sqlstruct.Scan(cr, rows))
	}
	return nil, nil
}
开发者ID:mclem,项目名称:cfssl,代码行数:19,代码来源:database_accessor.go


示例10: GetUnexpiredOCSPs

// GetUnexpiredOCSPs retrieves all unexpired OCSPRecord from db.
func GetUnexpiredOCSPs(db *sql.DB) (rrs []*OCSPRecord, err error) {
	rr := new(OCSPRecord)
	rows, err := db.Query(fmt.Sprintf(selectAllUnexpiredOCSPSQL, sqlstruct.Columns(*rr)))
	if err != nil {
		return nil, wrapCertStoreError(err)
	}
	defer rows.Close()

	for rows.Next() {
		err = sqlstruct.Scan(rr, rows)
		if err != nil {
			return nil, wrapCertStoreError(err)
		}
		rrs = append(rrs, rr)
	}

	return rrs, nil
}
开发者ID:jamesbjackson,项目名称:cfssl,代码行数:19,代码来源:certdb.go


示例11: GetUnexpiredCertificates

// GetUnexpiredCertificates gets all unexpired certificate from db.
func GetUnexpiredCertificates(db *sql.DB) (crs []*CertificateRecord, err error) {
	cr := new(CertificateRecord)
	rows, err := db.Query(fmt.Sprintf(selectAllUnexpiredSQL, sqlstruct.Columns(*cr)))
	if err != nil {
		return nil, wrapCertStoreError(err)
	}
	defer rows.Close()

	for rows.Next() {
		err = sqlstruct.Scan(cr, rows)
		if err != nil {
			return nil, wrapCertStoreError(err)
		}
		crs = append(crs, cr)
	}

	return crs, nil
}
开发者ID:jamesbjackson,项目名称:cfssl,代码行数:19,代码来源:certdb.go


示例12: cacheFetch

func cacheFetch(whereStr string, values []interface{}) ([]Cached, error) {

	queryStr := fmt.Sprintf("SELECT %s FROM cached", sqlstruct.Columns(Cached{}))
	rows, err := config.DB.Query(queryStr+" "+whereStr, values...)
	if err != nil {
		return []Cached{}, err
	}
	defer rows.Close()

	actions := []Cached{}
	for rows.Next() {
		var act Cached
		err := sqlstruct.Scan(&act, rows)
		if err == nil {
			actions = append(actions, act)
		}
	}

	return actions, nil
}
开发者ID:NelsonLeDuc,项目名称:CalmanBot,代码行数:20,代码来源:smartcache.go


示例13: GetOCSP

// GetOCSP retrieves a certdb.OCSPRecord from db by serial.
func (d *Accessor) GetOCSP(serial, aki string) (rrs []certdb.OCSPRecord, err error) {
	err = d.checkDB()
	if err != nil {
		return nil, err
	}

	rr := certdb.OCSPRecord{}
	rows, err := d.db.Query(fmt.Sprintf(selectOCSPSQL, sqlstruct.Columns(rr)), serial, aki)
	if err != nil {
		return nil, wrapSQLError(err)
	}
	defer rows.Close()

	if rows.Next() {
		err = sqlstruct.Scan(&rr, rows)
		if err != nil {
			return nil, wrapSQLError(err)
		}
		rrs = append(rrs, rr)
	}
	return rrs, nil
}
开发者ID:rolandshoemaker,项目名称:cfssl,代码行数:23,代码来源:database_accessor.go


示例14: GetUnexpiredOCSPs

// GetUnexpiredOCSPs retrieves all unexpired certdb.OCSPRecord from db.
func (d *Accessor) GetUnexpiredOCSPs() (rrs []*certdb.OCSPRecord, err error) {
	err = d.checkDB()
	if err != nil {
		return nil, err
	}

	rr := new(certdb.OCSPRecord)
	rows, err := d.db.Query(fmt.Sprintf(selectAllUnexpiredOCSPSQL, sqlstruct.Columns(*rr)))
	if err != nil {
		return nil, wrapSQLError(err)
	}
	defer rows.Close()

	for rows.Next() {
		err = sqlstruct.Scan(rr, rows)
		if err != nil {
			return nil, wrapSQLError(err)
		}
		rrs = append(rrs, rr)
	}

	return rrs, nil
}
开发者ID:mclem,项目名称:cfssl,代码行数:24,代码来源:database_accessor.go


示例15: GetUnexpiredCertificates

// GetUnexpiredCertificates gets all unexpired certificate from db.
func (d *Accessor) GetUnexpiredCertificates() (crs []*certdb.CertificateRecord, err error) {
	err = d.checkDB()
	if err != nil {
		return nil, err
	}

	cr := new(certdb.CertificateRecord)
	rows, err := d.db.Query(fmt.Sprintf(selectAllUnexpiredSQL, sqlstruct.Columns(*cr)))
	if err != nil {
		return nil, wrapSQLError(err)
	}
	defer rows.Close()

	for rows.Next() {
		err = sqlstruct.Scan(cr, rows)
		if err != nil {
			return nil, wrapSQLError(err)
		}
		crs = append(crs, cr)
	}

	return crs, nil
}
开发者ID:mclem,项目名称:cfssl,代码行数:24,代码来源:database_accessor.go


示例16: GetCertificate

// GetCertificate gets a certdb.CertificateRecord indexed by serial.
func (d *Accessor) GetCertificate(serial, aki string) (crs []certdb.CertificateRecord, err error) {
	err = d.checkDB()
	if err != nil {
		return nil, err
	}

	cr := certdb.CertificateRecord{}
	rows, err := d.db.Query(fmt.Sprintf(selectSQL, sqlstruct.Columns(cr)), serial, aki)
	if err != nil {
		return nil, wrapSQLError(err)
	}
	defer rows.Close()

	if rows.Next() {
		err = sqlstruct.Scan(&cr, rows)
		if err != nil {
			return nil, wrapSQLError(err)
		}
		crs = append(crs, cr)
	}

	return crs, nil
}
开发者ID:rolandshoemaker,项目名称:cfssl,代码行数:24,代码来源:database_accessor.go


示例17: updateLikes

func updateLikes() {
	queryStr := fmt.Sprintf("SELECT %s FROM groupme_posts WHERE posted_at >= NOW() - '1 day'::INTERVAL", sqlstruct.Columns(gmPost{}))

	rows, err := config.DB.Query(queryStr)
	if err != nil {
		return
	}
	defer rows.Close()

	groupedPosts := make(map[string][]gmPost)
	for rows.Next() {
		var post gmPost
		err := sqlstruct.Scan(&post, rows)
		if err == nil {
			slice := groupedPosts[post.GroupID]
			slice = append(slice, post)
			groupedPosts[post.GroupID] = slice
		}
	}

	token := os.Getenv("groupMeID")

	updated := make(map[int]int)

	for key, group := range groupedPosts {
		getURL := "https://api.groupme.com/v3/groups/" + key + "/likes?period=day&token=" + token
		resp, _ := http.Get(getURL)
		body, _ := ioutil.ReadAll(resp.Body)

		var wrapper gmMessageWrapper
		json.Unmarshal(body, &wrapper)

		for _, message := range wrapper.Response.Messages {
			for _, post := range group {
				if post.MessageID == message.MessageID() {
					updated[post.ID] = len(message.FavoritedBy)
				}
			}
		}
	}

	tx, err := config.DB.Begin()
	if err != nil {
		return
	}

	stmt, _ := config.DB.Prepare("UPDATE groupme_posts SET likes=$1 WHERE id=$2")
	for updateID, likeCount := range updated {
		stmt.Exec(likeCount, updateID)
	}
	tx.Commit()
}
开发者ID:NelsonLeDuc,项目名称:CalmanBot,代码行数:52,代码来源:gmcachemanager.go



注:本文中的github.com/kisielk/sqlstruct.Columns函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang sqlstruct.Scan函数代码示例发布时间:2022-05-23
下一篇:
Golang gotool.ImportPaths函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap