Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

finding local postgresql “database_url”

Tags:

postgresql

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.

like image 550
Paul Avatar asked Oct 13 '14 02:10

Paul


People also ask

Where is my local PostgreSQL database?

Use \l or \l+ in psql to show all databases in the current PostgreSQL server. Use the SELECT statement to query data from the pg_database to get all databases.

How do you check if Postgres is running locally?

basically just type "systemctl status postgresql-xx" where xx is the version of your PostgreSQL instance. ex: systemctl status posgresql-10.

What is the local host for PostgreSQL?

The PostgreSQL database service is available on localhost and the default PostgreSQL port is 5432 . A default user ( hosting-db ) and database ( postgres ) exist so you can quickly test your connection and perform management tasks.


4 Answers

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
like image 189
Thomas Morrison Avatar answered Oct 21 '22 21:10

Thomas Morrison


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

like image 25
Blaine McMahon Avatar answered Oct 21 '22 21:10

Blaine McMahon


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

like image 37
Marichyasana Avatar answered Oct 21 '22 22:10

Marichyasana


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

like image 1
user8851623 Avatar answered Oct 21 '22 20:10

user8851623