Connecting MySQL with Python

Published July 26, 2025 By Sai Sree Ram Gundepudi

Python Example

import mysql.connector
conn = mysql.connector.connect(user='root', password='pass', database='employees')
cursor = conn.cursor()
cursor.execute('SELECT * FROM employees')
for row in cursor:
  print(row)

Was this solution helpful?

Your feedback helps improve our technical knowledge repository.

Share this article