Connect to an existing Heroku Postgres database for the Sinatra application

I use Salesforce for my CRM, but you need to request data (multiple records, therefore no Zapier) for a Heroku-based Sinatra application. Heroku provides a service that regularly replicates Salesforce objects to Postgres tables, which retrieve my data from Salesforce.

I precoded the Sinatra application and posted it on Heroku, so I am a little familiar with the process of creating dev db locally, and then dragged it to production through a lot of tutorials. However, I ran into the problem of finding any information that would allow me to connect to the existing Postgres DB database, which is already filled with the data I need, while there is no need to create and connect to the local dev db.

Heroku provides me with the following enter image description here

How and where can I connect these various credentials safely, so my next files have the correct information for connecting to Venue__c and Spaces__c tables?
app.rb
/ config
- database.yml
- environment.rb

+4
3

, ActiveRecord, database.yml. , , - :

# database.yml
development:
  adapter: postgresql
  encoding: unicode
  database: your_database
  username: your_user
  password: your_password
  host: your_host
  port: your_port

# or alternatively, using the URI
development:
  url: postgres://your_user:your_password@your_host/your_database
+3

Heroku URL- . ENV.fetch("DATABASE_URL"). ORM , . Sequel Sequel.connect(ENV.fetch("DATABASE_URL")).

, , ActiveRecord, ActiveRecord::Base.establish_connection(...), , , URL ( ). database.yml, Rails, environment.rb , .

0
source

Source: https://habr.com/ru/post/1673163/


All Articles