This document says to set DATABASE_URL=postgres://$(whoami) this to maintain parity between local and pro dbs. But what should I replace "whoami" with?
I have installed PostGreSql on my machine. How to I perform CRUD operations?
That whoami
will return username of the current user
when invoked. As the documentation said, you just need to type the below in command prompt (no need to replace whoami
), depends on your OS:
Linux / Mac:
export DATABASE_URL=postgres://$(whoami)
Windows:
set DATABASE_URL=postgres://$(whoami)
After set up Postgres, you can use psql
client to access the database. As you asked in comment regarding how to run .sql
file, here's the steps:
In command prompt, type "psql"
. You are now connected to your database.
Inside psql
, type "\i your_sql_file.sql"
. This execute the your_sql_file.sql
file.