Connect Amber to Postgress

I had Postgress already installed, and installed crystal and amber, according to the instructions, but I’m not able to connect to the server.

amber db create migrate
Connection unsuccessful: postgres://postgres:password@localhost:5432/postgres

do I need to somehow select a server, and give the password, or look in path to see where Postgress is?

Are you sure that the username and password is correct?

I don’t know how to change the username or password, can I set up postgress without a passoword?

the bash command (Ubuntu 20.04.3 LTS)

psql -h server.domain.org database user

creates the error

psql: error: connection to server at "server.domain.org" (65.254.244.180), port 5432 failed: Connection refused

Is the server running on that host and accepting TCP/IP connections?

Do I set the TCP/IP in pgAdmin 4 ?

I’m far from an expert on this. All I usually do is type psql with no arguments in the terminal to access the database.

In the code I use postgres as both username and password.

postgres://postgres:postgres@localhost:5432/postgres

how do I put that in bash?

It seems like it should be straight forward, so that’s why I’m confussed. I don’t think I messed anything up.

According to their docs it looks like you need to create a file (if not already created) with the name {project_name}/config/environments/{current_environment}.yml, e.g. if your app is named todo then it should be todo/config/environments/development.yml.

This file should look something like (docs)

# other settings ...

database_url: postgres://postgres:@localhost:5432/database_name

# other settings ...

Now you should be able to run e.g. amber db create and other db commands.

where is this file created? I think I have Postgress in root , and i’m keep forgeting to access root.

It should be in your app’s config/environments folder

I don’t see that in amber-stable , do I create a new folder in home?

It should be inside your app.

Their docs says to run amber new app_name to create a new app. This app should have a config folder.

Now modify app_name/config/environments/development.yml as I described above.

amber new pet-tracker

Does this create an app called pet-tracker?

According to their docs, yes

OK, get it now

database_url: postgres://postgres:password@localhost:5432/pet_tracker_development

is the name in the .yml

there are comments

# ssl_key_file:
# ssl_cert_file:

do these have anything to do with a password?

I’d recommend to just ignore those for now.

ok so I showed you that the line you suggested to change is the same, what do I look at now?

Now try amber db create

Connection unsuccessful

Does it matter what directory I’m in?

It shouldn’t matter.

postgres://postgres:password@localhost:5432/pet_tracker_development

is your postgres user’s password password? Otherwise try change it to postgres

postgres://postgres:postgres@localhost:5432/pet_tracker_development