I'm fairly new to posgres and Go, but have been struggling for a while on this. I'm currently trying to send a query to retrieve everything from a table. When I try to use
SELECT * FROM land_registry_price_paid_uk
within postgres, it shows everything, but when I do the same using Query, I get.
sql: expected 16 destination arguments in Scan, not 1
This is the current code that I have.
fmt.Printf("user: %s, password: %s, dbName: %s", user, password, dbName)
connectionString := fmt.Sprintf("user=%s password=%s dbname=%s sslmode=%s", user, password, dbName, "disable")
var err error
a.DB, err = sql.Open("postgres", connectionString)
if err != nil {
log.Fatal(err)
}
rows, err := a.DB.Query("SELECT ( * ) FROM land_registry_price_paid_uk")
if err != nil {
log.Fatal(err)
}
defer rows.Close()
println(rows)
for rows.Next() {
var name string
if err := rows.Scan(&name); err != nil {
log.Fatal(err)
}
fmt.Printf("this is something: %s
", name)
Any help is appreciated.