Documentation
¶
Index ¶
Constants ¶
const (
// Driver is a driver name.
Driver = "postgres"
)
Variables ¶
This section is empty.
Functions ¶
func CheckConnection ¶
CheckConnection returns an error if connection is not ready. Otherwise, return nil. CheckConnection calls db.Ping to check if the connection is open, but that doesn't guarantee the database is ready to execute a query. So in addition to using db.Ping, CheckConnection also performs one-round-trip queries to the database.
Use context.WithTimeout make a deadline.
func Open ¶
Open knows how to open a new database connection. The Open just validate its arguments without creating a connection to the database. To verify that the data source name is valid, call database.CheckConnection.
The returned DB is safe for concurrent use by multiple goroutines and maintains its own pool of idle connections. Thus, the Open function should be called just once. It is rarely necessary to close a DB.