本文整理汇总了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)
}
示例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
}