PostgreSQL is a powerful, open source object-relational database system. PostgreSQL runs on all major operating systems. PostgreSQL follows ACID property of DataBase system and has the support of triggers, updatable views and materialized views, foreign keys.
To connect PostgreSQL we use psycopg2 . It is the best and most friendly Database adapter in python language. It is both Unicode and Python3 friendly.
Installation Required –
pip install psycopg2
Let’s get started and understand PostgreSQL connection in parts.
Step #2: Declare Cursor
Allows Python code to execute PostgreSQL command in a database session.
Step #3: Write your SQL Query and execute it.
Step #4: Close the connection
- Getting started with Jupyter Notebook | Python
- Check if a Thread has started in Python
- Python | Getting started with SymPy module
- Getting started with Scikit-image: image processing in Python
- How Should a Machine Learning Beginner Get Started on Kaggle?
- Python | Index of Non-Zero elements in Python list
- Important differences between Python 2.x and Python 3.x with examples
- Python | Convert list to Python array
- Reading Python File-Like Objects from C | Python
- Python | Merge Python key values to list
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Add Logging to Python Libraries
- Python | Sort Python Dictionaries by Key or Value
- Python | Add Logging to a Python Script
- Python | Visualizing O(n) using Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.