This commit is contained in:
Mark McGranaghan
2012-09-23 12:01:19 -07:00
parent 35c4455331
commit e91edf0194
7 changed files with 68 additions and 60 deletions

View File

@@ -1,11 +1,11 @@
// ## Postgres
package main
import (
_ "github.com/bmizerany/pq"
"database/sql"
"fmt"
"time"
)
import _ "github.com/bmizerany/pq"
import "database/sql"
import "time"
import "fmt"
func main() {
db, openErr := sql.Open("postgres", "dbname=gobyexample sslmode=disable")
@@ -50,16 +50,7 @@ func main() {
fmt.Println(dropRep)
}
// == running
// # start postgres
// $ createdb gobyexample
// $ cd xx-postgres
// $ go get
// $ ./xx-postgres
// == todo
// connection pooling
// concurrency
// re-connection
// errors
// explain
// todo: connection pooling & concurrency
// todo: re-connection
// todo: errors
// todo: database_url

10
076-postgres/postgres.sh Normal file
View File

@@ -0,0 +1,10 @@
# First, be sure that you've installed Postgres
# and have a server running locally at port 5432.
# Then create an example database.
$ createdb gobyexample
# Now install the dependencies for the postgres
# example and try running it.
$ go get github.com/bmizerany/pq
$ go run postgres.go