// Connect to the database
// ...
type Row struct {
language string
percentage float32
}
// SQL query execution
statement, _ := conn.Prepare(`
SELECT
Language, Percentage
FROM countrylanguage
WHERE CountryCode = 'RUS'
ORDER BY Percentage DESC`)
// Get first row
result := statement.QueryRow()
row := new(Row)
result.Scan(&row.language, &row.percentage)
fmt.Println(row)
// Get all rows
rows, _ := statement.Query()
for rows.Next() {
row := new(Row)
rows.Scan(&row.language, &row.percentage)
fmt.Println(row)
}
// Close the connection
conn.Close()