Easily add Postgresql database to your Kemal application.
Add this to your application's
dependencies: kemal-pg: github: sdogruyol/kemal-pg
This middleware adds
Postgresql connection pool to Kemal as a middleware.
require "kemal" require "kemal-pg" pg_connect "postgres://user@host:5432/your_db" # Make sure to yield `env`. get "/" do |env| users = conn.exec("SELECT * FROM users") # Release the connection after you are done with exec release "Hello from postgresql" end
You can configure the connection pool capacity and timeout like:
pg_connect "postgres://user@host:5432/your_db", capacity: 10, timeout: 0.1
The default value for connection pool capacity is
25 and timeout is
- Fork it ( https://github.com/sdogruyol/kemal-pg/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- sdogruyol Sdogruyol - creator, maintainer