25

I'm following these instructions (https://github.com/assemblymade/assemblycoins) to get a postgresql server connected.

I am told to: "set DATABASE_URL local variable to postgres database url"

I'm not too sure where to find this, it doesn't seem like an easy thing to find. (Sorry, i'm pretty new to Postgresql if this is a real amateur question)

For a bit more context, I installed postgresql from Enterprise DB and can successfully run a postgresql database on PGAdmin.

1

5 Answers 5

14

You can display your connection info if logged into postgres shell with command:

\conninfo

this will display the database you are connected to as well as the user logged on

Sign up to request clarification or add additional context in comments.

Comments

10

See The docs The general form for a connection URI is:

postgresql://[user[:password]@][netloc][:port][,...][/dbname][?param1=value1&...]

You probably need to set you environment variable DATABASE_URL to something like

set DATABASE_URL=user:password@localhost/dbname

Comments

3

Looking at file main.py line 22 contains "os.environ['DATABASE_URL']" you should set the environment variable DATABASE_URL on your computer to a value that is the location of your database. Eg: set DATABASE_URL=C:\Users\Philip\mydatabasefile

7 Comments

thanks @Marichyasana. I tried the following: DATABASE_URL= "postgresql://localhost/postgres" under line 22. this matches the information in my current local postgres database. However when I ran "python main.py" I got the error: "KeyError: 'DATABASE_URL". I'm not too sure why it's not processing my database url.
@Paul: the comment on line 22 seems like it tells you that the format should be: "postgresql://localhost/"+dbname Is your databasename "postgres", or more likely "myDatabase"
I made the change according to the comment in Line 22. so it now looks like DATABASE_URL="postgresql://localhost/"+dbname", where dbname is set to "postgres" (this is the name of my database, at least according to pgadmin) I still get the same KeyError when running python main.py
Did you change the file or the environment variable?
I don't have postgres so I'm unable to make more suggestions.
|
3

This is the method I often use:

postgres://[user]:[password]@[host]:[port]/[database]

1 Comment

Simple, concise, and to the point!
1

This is the most up to date URI format for sqlalchemy

Replace the following variables: 1. username 2. password 3. dbname

URI postgresql+psycopg2://username:password@localhost/dbname

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.