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 Plotly-Python
- Python | Getting started with SymPy module
- Getting started with Jupyter Notebook | Python
- Getting started with Python for Automated Trading
- Check if a Thread has started in Python
- Getting started with Scikit-image: image processing in Python
- ML | Getting Started With AlexNet
- How Should a Machine Learning Beginner Get Started on Kaggle?
- Reusable piece of python functionality for wrapping arbitrary blocks of code : Python Context Managers
- Python - Read blob object in python using wand library
- MySQL-Connector-Python module in Python
- Reading Python File-Like Objects from C | Python
- twitter-text-python (ttp) module - Python
- Python | Index of Non-Zero elements in Python list
- Important differences between Python 2.x and Python 3.x with examples
- Python | Merge Python key values to list
- Python | PRAW - Python Reddit API Wrapper
- Python | Convert list to Python array
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Sort Python Dictionaries by Key or Value
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.