python
pip install python-sql
python
from sql import MySQL
db = MySQL.connect(
host="localhost",
user="root",
password="password123",
database="mydatabase"
)
cursor = db.cursor()
python
sql = "SELECT * FROM customers"
cursor.execute(sql)
results = cursor.fetchall()
for row in results:
print(row)
python
sql = "SELECT * FROM customers WHERE country = 'China'"
cursor.execute(sql)
results = cursor.fetchall()
for row in results:
print(row)