pip install MySQL-Python
python
import MySQLdb
python
conn = MySQLdb.connect(host="localhost", user="root", passwd="password", db="database_name")
python
cursor = conn.cursor()
cursor.execute("SELECT * FROM table_name")
results = cursor.fetchall()
for row in results:
conn.close()
python
cursor = conn.cursor()
sql = "INSERT INTO table_name (column1, column2) VALUES (%s, %s)"
data = ("value1", "value2")
cursor.execute(sql, data)
conn.commit()
python
try:
except Exception as e: