To retrieve the data from a table we use, SELECT column_names FROM table_name statement.
Getting All Records From Table
import mysql.connector as mysql
db = mysql.connect(
host="localhost",
user="root",
passwd="root@123",
database="realprogrammer"
)
cursor = db.cursor()
## defining the Query
query = "SELECT * FROM user"
## getting records from the table
cursor.execute(query)
records = cursor.fetchall()
## Showing data
for record in records:
print(record)