mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
add db.Ping() example
parent
0b80d6a417
commit
c7758ebedc
@ -23,7 +23,13 @@ Where driver specifies a database driver and dataSourceName
|
||||
specifies database-specific connection information
|
||||
such as database name and authentication credentials.
|
||||
|
||||
Note that Open does not directly open a database connection: this is deferred until a query is made. To verify that a connection can be made before making a query, use the Ping function.
|
||||
Note that Open does not directly open a database connection: this is deferred until a query is made. To verify that a connection can be made before making a query, use the Ping function:
|
||||
|
||||
```
|
||||
if err := db.Ping(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
```
|
||||
|
||||
After use, the database is closed using Close.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user