Python programming language is a high-level and object-oriented programming language developed by Guido Van Rossum, when he was working at CWI (Centrum Wiskunde & Informatica) which is a National Research Institute for Mathematics and Computer Science in the Netherlands.
In this era of machine learning and AI, the language has become so versatile that it can be used for performing multiple tasks. And backend development is one of them.
Using Python, we can access and manipulate databases and perform other backend tasks. Python has a library named 'pymysql' to perform the mySQL task and execute the queries.
We need to access the database using Python and then get the content of the table we have created in here, create an SQL table.
And then we will print the content of this table on screen.
Steps to display content of table in python:
- Step 1: Connect to database using connect() method.
- Step 2: Create a command to execute the query using cursor() method.
- Step 3: And then we have used the fetchAll() method which is stored in rows.
- Step 4: Print all elements of rows.
Program to display contents of table in Python
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer