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
- Check if a Thread has started in Python
- Python | Getting started with SymPy module
- Getting started with Jupyter Notebook | Python
- Getting started with Scikit-image: image processing in Python
- How Should a Machine Learning Beginner Get Started on Kaggle?
- Python | Merge Python key values to list
- Python | Convert list to Python array
- Reading Python File-Like Objects from C | Python
- Important differences between Python 2.x and Python 3.x with examples
- Python | Index of Non-Zero elements in Python list
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Sort Python Dictionaries by Key or Value
- Python | Add Logging to a Python Script
- Python | Add Logging to Python Libraries
- 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 firstname.lastname@example.org. 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.