I am trying to query a database that I know has data in it from directly querying within pgadmin. When I query using the following code it returns no results:
const DATABATE_URL = "postgres://postgres:pw@localhost:5432/postgresdb"
conn, err := pgx.Connect(context.Background(), DATABATE_URL)
defer conn.Close(context.Background())
if err != nil {
fmt.Printf("Connection failed: %v\n", err)
os.Exit(-1)
}
stmt := "SELECT * FROM nodes"
rows, err := conn.Query(context.Background(), stmt, nil)
if err != nil {
fmt.Fprintf(os.Stderr, "QueryRow failed: %v\n", err) //error outs here "expected 0 arguments, got 1"
os.Exit(1)
}
for rows.Next() {
var results string
err = rows.Scan(&results)
if err != nil {
fmt.Fprintf(os.Stderr, "QueryRow failed: %v\n %n", err)
os.Exit(1)
}
fmt.Println(results)
}
When I directly connect to the database through goland and pgadmin and query with the same statement I can see all the data. What am I missing here?