Hi,
I am facing the following problem:
I am opening a Postgres connection without any error (my GO app and Postgres DDBB live within a container)
//Connect to Postgres DDBB
db, err := sql.Open("postgres", *databaseURL)
if err != nil {
panic(fmt.Sprintf("Got error when connect database, the error is '%v'", err))
}
So, no errors display when executing this code, but when I do
err := db.QueryRow("select id from ir_attachment where NAME='$1'", pdfFile).Scan(&pi_id)
if err == sql.ErrNoRows {
pi_id = 0
fmt.Printf("Error no rows")
} else if err != nil {
log.Fatal(err)
fmt.Printf("Error fatal!")
}
I only get a time out…none of the above errors are shown either…
2017/01/11 11:32:55 dial tcp 10.0.0.6:5432: getsockopt: connection timed out
sql.Open only creates a connection pool, checks that the driver is registered. The firt use creates the first connection - so use db.Ping to check the db connection parameters!