Skip to content

muralialakuntla3/flask-postgresql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

Python: flask-postgresql Deployment

Install PostgreSql

sudo apt update
sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
. /etc/os-release
sudo sh -c "echo 'deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $VERSION_CODENAME-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
sudo apt update
sudo apt -y install postgresql-16

Connect to Database

psql -h azure2501db.postgres.database.azure.com -p 5432 -U adminuser postgres
image

Create database and Table for application

\list
CREATE DATABASE demo_app;
\c demo_app
\dt
image

Create Table

CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    name VARCHAR(100),
    email VARCHAR(100),
    number VARCHAR(20)
);

image

check the table and table data

\dt
SELECT * FROM "users";
exit;
image

download the code into server and run the application

ls
git clone https://github.com/muralialakuntla3/flask-postgresql.git
cd flask-postgresql
ls
image

Install dependencies

sudo apt install python3-flask -y 
sudo apt install python3-psycopg2 -y

image image

update database details in app.py file

vi app.py

image

run application

python3 app.py 

image

check the application

  • update the network security group to allow port 5000
image - browse the application - public-ip:5000 ![image](https://github.com/user-attachments/assets/b1c14f42-373e-40b4-93f1-0968ae38b8d9)

check the database

  • connect the database and verify the data
psql -h myappdatabase.postgres.database.azure.com -p 5432 -U adminuser demo_app
\dt
SELECT * FROM users;
image

About

postgres sql python flask app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages