当前位置: 首页>>代码示例>>Golang>>正文


Golang sqlstruct.Columns函数代码示例

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


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


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