Managing PostgreSQL Objectively
Intro
I apply Object Oriented Programming for managing PostgreSQL database where database has its own class along with methods of creating table, inserting data or selecting row(s).
Features
App includes following features:
Demo
PostgreSQL - Python connection:
- Upper window is the PostgreSQL database - I operate it using Shell terminal.
- Second window is windows command prompt which I use to call python script.
- Using argv function from sys library, I can get customized parameters from termial running python command like: setup, add, list.
- Every run of python main.py script connects to ostgreSQL database and teminates connection when finishes.
- Setup parameter creates 'clients' table.
- Add parameter performs INSERT on 'clients' table.
- List parameter performs SELECT * on 'clients' table.
Setup
Python library installation required.
- pip install python-dotenv
- pip install psycopg2