本文整理匯總了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
}