xxxxxxxxxx
# Make sure you install the connector API: !pip install mysql-connector-python
import mysql.connector
# Create a connection
db_name = mysql.connector.connect(
host="localhost",
user="yourusername",
password="yourpassword",
database="yourdatabase"
)
# Create a cursor
db_cursor = db_name.cursor()
# Execute SQL queries
db_cursor.execute("SELECT * FROM table_name")
result = db_cursor.fetchall()
# Print all result
for x in result:
print(x)
xxxxxxxxxx
# Make sure you install the connector API: !pip install mysql-connector-python
import mysql.connector
# Create a connection
db_name = mysql.connector.connect(
host="localhost",
user="yourusername",
password="yourpassword",
database="yourdatabase"
)
# Create a cursor
db_cursor = db_name.cursor()
# Execute SQL queries
db_cursor.execute("SELECT * FROM table_name")
result = db_cursor.fetchall()
# Print all result
for x in result:
print(x)