lxd/db/query/count.go
func CountAll(tx *sql.Tx) (map[string]int, error) {
	tables, err := SelectStrings(tx, "SELECT name FROM sqlite_master WHERE type = 'table'")
	if err != nil {
		return nil, errors.Wrap(err, "Failed to fetch table names")
	}

	counts := map[string]int{}
	for _, table := range tables {
		count, err := Count(tx, table, "")
		if err != nil {
			return nil, errors.Wrapf(err, "Failed to count rows of %s", table)
		}
		counts[table] = count
	}

	return counts, nil
}
func CountAll(tx *sql.Tx) (map[string]int, error) {
	tables, err := SelectStrings(tx, "SELECT name FROM sqlite_master WHERE type = 'table'")
	if err != nil {
		return nil, errors.Wrap(err, "Failed to fetch table names")
	}

	counts := map[string]int{}
	for _, table := range tables {
		count, err := Count(tx, table, "")
		if err != nil {
			return nil, errors.Wrapf(err, "Failed to count rows of %s", table)
		}
		counts[table] = count
	}

	return counts, nil
}
// CountAll returns a map associating each table name in the database
// with the total count of its rows.