Update README

This commit is contained in:
Jinzhu 2013-11-03 11:38:53 +08:00
parent 92f790c463
commit 63a9e5e3ae

View File

@ -57,7 +57,14 @@ type Address struct { // TableName: `addresses`
## Opening a Database
```go
db, err = Open("postgres", "user=gorm dbname=gorm sslmode=disable")
import "github.com/jinzhu/gorm"
import _ "github.com/lib/pq"
db, err := Open("postgres", "user=gorm dbname=gorm sslmode=disable")
// Set the maximum idle database connections
db.SetPool(100)
// Gorm is goroutines friendly, so you can create a global variable to keep the connection and use it everywhere like this
@ -69,9 +76,6 @@ func init() {
panic(fmt.Sprintf("Got error when connect database, the error is '%v'", err))
}
}
// Set the maximum idle database connections
db.SetPool(100)
```
## Struct & Database Mapping