Edwin has just finished learning about the database/sql package, now he wants to create a query that selects all the columns from the artists table of the chinook.db.
Below is the code Edwin has written so far:
...
func main() {
db, err := sql.Open("sqlite3", "chinook.db")
if err != nil {
log.Fatal()
}
defer db.Close()
// What function allows us to fetch data from the database?
rows, err := db.?("SELECT ?, ? FROM ?")
if err != nil {
log.Fatal(err)
}
defer rows.Close()
... // create variables for the columns and iterate over the rows
}
The artist table only has two columns: artistid and name. Your task is to help Edwin write the required code, including the correct function name and the proper query to SELECT all the columns from the artists table below.
Take notice that your answer should not include the
rows, err := code part; it should only include the correct function and query after it, like this: db.?("SELECT, ?, ? FROM ?")