Created
May 5, 2016 08:57
-
-
Save dankeder/33192df083703aedbaf5d4c42cb0f999 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"fmt" | |
pg "gopkg.in/pg.v4" | |
) | |
func main() { | |
db := pg.Connect(&pg.Options{ | |
Addr: "192.168.56.100:5432", | |
Database: "mydb", | |
User: "myuser", | |
Password: "mypass", | |
SSL: false, | |
// DisableRateLimiting: true, | |
}) | |
for i := 0; i < 1000; i++ { | |
// This is OK: | |
// _, err := db.Query(&model, `SELECT 1 AS x`) | |
// if err != nil { | |
// fmt.Fprintf(os.Stderr, "%v", err) | |
// } | |
// This crashes after 34 iterations with error: | |
// pg: you open connections too fast | |
_, err := db.CopyTo(os.Stdout, `COPY mytable TO STDOUT`) | |
if err != nil { | |
fmt.Fprintf(os.Stderr, "%v\n", err) | |
os.Exit(1) | |
} | |
fmt.Printf("i=%v\n", i) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment