Does db.connect test the connection

I am using a PostgreSQL database.

After each query to the database, I call db.close and then when the database needs to be queried again I call something like:

db.Host = "123.456.0.789"
db.UserName = "postgres"
db.Password = "dbexample"
db.DatabaseName = "postgres"

Return db.connect

I was wondering what db.connect is actually doing.

Does it:

Test the connection:
if connected, returns True
if Not connected, tries to reconnect (and then returns the result of the attempt to reconnect)

Or does it just reconnect to the database each time.

It just seems that the database does not lose the connection instantly when db.close is called, and calls to the database within a certain period of time seem to happen faster than the time it takes for the initial connect.

Just wondering.

the connection is open until you close it
to reconnect you have to open it

OK, so the connection is actually being re-established each time.

I thought there might be a delay between calling db.close and the database actually being closed.

Not necessarily true. The connection could close on its own for a variety of reasons (timeout, network loss). I don’t think there is any penalty for reusing the Connect.

ok Yes Bob that is True