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


Golang DB.QueryRow方法代码示例

本文整理汇总了Golang中github.com/BurntSushi/goim/imdb.DB.QueryRow方法的典型用法代码示例。如果您正苦于以下问题:Golang DB.QueryRow方法的具体用法?Golang DB.QueryRow怎么用?Golang DB.QueryRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/BurntSushi/goim/imdb.DB的用法示例。


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

示例1: tableSize

// tableSize returns a pretty string indicating the size in table. Row count
// is always include, but the size on disk is only included if it's supported
// by the database.
// Note that 'name' is assumed to be SQL-safe.
func tableSize(db *imdb.DB, name string) string {
	count := csql.Count(db, sf("SELECT COUNT(*) AS count FROM %s", name))
	if db.Driver == "sqlite3" {
		return sf("%d rows", count)
	}
	var size string
	q := sf("SELECT pg_size_pretty(pg_relation_size('%s'))", name)
	csql.Scan(db.QueryRow(q), &size)
	return sf("%d rows (%s)", count, size)
}
开发者ID:BurntSushi,项目名称:goim,代码行数:14,代码来源:cmd_size.go

示例2: databaseSize

// databaseSize returns a pretty string indicating the size of the entire
// database on disk.
func databaseSize(db *imdb.DB, dsn string) string {
	if db.Driver == "sqlite3" {
		fi, err := os.Stat(dsn)
		csql.Panic(err)
		return prettyFileSize(fi.Size())
	}
	var size string
	q := sf("SELECT pg_size_pretty(pg_database_size(current_database()))")
	csql.Scan(db.QueryRow(q), &size)
	return size
}
开发者ID:BurntSushi,项目名称:goim,代码行数:13,代码来源:cmd_size.go


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