Reputation: 19505
I feel uncomfortable saving my password in a file:
require 'pg'
conn = PG::Connection.open(host: 'server.example.com', password: 'hello_everyone')
Also, is there a way to determine or ensure that the transmission is encrypted? I am just worried about the implications of running my app locally, when it must connect to a remote database (I am worried about all the data, including the authentication credentials, being sent in the clear).
Upvotes: 0
Views: 692
Reputation: 23713
Regarding the password:
I would recommend setting it in an ENV variable. Take a look at dotenv gem. Basically, you are going to be able to do something like:
require 'pg'
conn = PG::Connection.open(host: ENV['database_host'], password: ENV['database_password'])
The values that are loaded into ENV will be stored in a file (.env
) which you should not commit.
Regarding data encryption
You should take a look at SSH tunneling to connect to the remote DB.
Upvotes: 1