Skip to content

Commit

Permalink
#19 doc
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Oct 18, 2019
1 parent acd550d commit 5404380
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ From inside your app you may find this class useful:
require 'pgtk/pool'
pgsql = Pgtk::Pool.new(Pgtk::Wire::Yaml.new('config.yml'))
pgsql.start(5) # Start it with five simultaneous connections
```

You can also let it pick the connection parameters from the environment
variable `DATABASE_URL`, formatted like
`postgres://user:password@host:5432/dbname`:


```ruby
pgsql = Pgtk::Pool.new(Pgtk::Wire::Env.new)
```

Now you can fetch some data from the DB:

```ruby
name = pgsql.exec('SELECT name FROM user WHERE id = $1', [id])[0]['name']
```

Expand Down

0 comments on commit 5404380

Please sign in to comment.