All Courses

Python PostgreSQL - Introduction

Gourav Mishra

4 years ago

Python PostgreSQL | Insideaiml
PostgreSQL is a powerful, open-supply object-relational database system. It has extra than 15 years of lively improvement segment and a validated structure that has earned it robust popularity for reliability, statistics integrity, and correctness.
To speak with PostgreSQL the use of Python you want to put in psycopg, an adapter supplied for python programming, the modern model of that is psycog2.
Psycopg2 become written with the intention of being very small and fast, and strong as a rock. It is to be had below PIP (package deal supervisor of python)

Installing Psycog2 using PIP

First of all, make sure python and PIP are installed in your system properly and, PIP is up-to-date.
To upgrade PIP, open command prompt and execute the following command −

C:\Users\Tutorialspoint>python -m pip install --upgrade pip
Collecting pip
   Using cached 
https://files.pythonhosted.org/packages/8d/07/f7d7ced2f97ca3098c16565efbe6b15fafcba53e8d9bdb431e09140514b0/pip-19.2.2-py2.py3-none-any.whl
Installing collected packages: pip
   Found existing installation: pip 19.0.3
      Uninstalling pip-19.0.3:
         Successfully uninstalled pip-19.0.3
Successfully installed pip-19.2.2
Then, open a command prompt in admin mode and execute the pip install psycopg2-binary command as shown below −

C:\WINDOWS\system32>pip install psycopg2-binary
Collecting psycopg2-binary
   Using cached 
https://files.pythonhosted.org/packages/80/79/d0d13ce4c2f1addf4786f4a2ded802c2df66ddf3c1b1a982ed8d4cb9fc6d/psycopg2_binary-2.8.3-cp37-cp37m-win32.whl
Installing collected packages: psycopg2-binary
Successfully installed psycopg2-binary-2.8.3

Verification

To verify the installation, create a sample python script with the following line in it.
import mysql.connector
If the installation is successful, when you execute it, you should not get any errors −
D:\Python_PostgreSQL>import psycopg2
D:\Python_PostgreSQL>
For more related articles and courses visit InsideAIML

Submit Review