Pakyow application with PostgreSQL database

Can someone explain how to use PostgreSQL database with Pakyow app?

I have created a Pakyow application and I have a PostgreSQL database, but I do not know how to set up the application to use the database.

+3


source to share


1 answer


Pakyow does not have built-in database support, but is compatible with any Ruby ORM (see docs ). Sequel is my library for working with databases in Pakyow. To get Sequel to work in your application, you first need to add sequel

and pg

(since you want to use Postgres) to your Gemfile:

gem 'sequel'
gem 'pg'

      

Then you need to configure the adapter in app.rb

. The best place to do this is in the block configure

for each environment. For example, this will allow you to configure your adapter for development:



$db = Sequel.connect('postgres://user:password@host:port/database_name')

      

You can access the $db

global in your application.

See the Continue documentation for information on accessing your data through direct queries or models.

+4


source







All Articles