lxd/db/query/config.go
func SelectConfig(tx *sql.Tx, table string, where string, args ...interface{}) (map[string]string, error) {
	query := fmt.Sprintf("SELECT key, value FROM %s", table)
	if where != "" {
		query += fmt.Sprintf(" WHERE %s", where)
	}

	rows, err := tx.Query(query, args...)
	if err != nil {
		return nil, err
	}
	defer rows.Close()

	values := map[string]string{}
	for rows.Next() {
		var key string
		var value string

		err := rows.Scan(&key, &value)
		if err != nil {
			return nil, err
		}

		values[key] = value
	}

	err = rows.Err()
	if err != nil {
		return nil, err
	}

	return values, nil
}
func SelectConfig(tx *sql.Tx, table string, where string, args ...interface{}) (map[string]string, error) {
	query := fmt.Sprintf("SELECT key, value FROM %s", table)
	if where != "" {
		query += fmt.Sprintf(" WHERE %s", where)
	}

	rows, err := tx.Query(query, args...)
	if err != nil {
		return nil, err
	}
	defer rows.Close()

	values := map[string]string{}
	for rows.Next() {
		var key string
		var value string

		err := rows.Scan(&key, &value)
		if err != nil {
			return nil, err
		}

		values[key] = value
	}

	err = rows.Err()
	if err != nil {
		return nil, err
	}

	return values, nil
}
// SelectConfig executes a query statement against a "config" table, which must
// have 'key' and 'value' columns. By default this query returns all keys, but
// additional WHERE filters can be specified.
//
// Returns a map of key names to their associated values.