Install postgres using the below command:
sudo apt-get install postgresql postgresql-contrib
To verify installation, run the command:
sudo -u postgres psql -c "SELECT version();"
Create User and DataBase:
sudo su - postgres -c "createuser yourusername"
sudo su - postgres -c "createdb yourdbname"
Grant privileges on the database to the user which you created in the previous commands:
sudo -u postgres psql
grant all privileges on yourdbname to yourusername;
alter user yourusername with password 'yourpassword';
Run following to exit from psql:
\q
To Enable remote access to postgresql,by editing:
sudo vi /etc/postgresql/10/main/postgresql.conf
Change the line :
"listen_addresses = 'localhost' " to "listen_addresses = '*' "
Save and exit the file
Restart postgresql:
sudo /etc/init.d/postgresql restart
Execute these commands in your terminal creates a new folder:
mkdir new_folder
cd new_folder
Execute these commands to create virtual environment:
python3 -m venv env
source env/bin/activate
Install requirements.txt using pip:
pip install -r requirements.txt
Run the following commands in terminal:
These commands creates a schema in the database
python3 manage.py db init
python3 manage.py db migrate
python3 manage.py db upgrade
Before running the app we have to connect the db to flask app. We can do so by changing the DATABASE URL in the _init_.py file inside the jobfinder folder:
DATABASE_URL = "postgresql://yourusername:password@yourIP:yourport/yourdbname"
Run the following command from the root of project directory
python3 manage.py runserver
Now Open the browser and hit the url:
- localhost:5000
or the one in your terminal.