First, you have to the mysql.connector
. In case you are uncertain of the best way to get this setup, check with The best way to Set up MySQL Driver in Python.
The best way to Restrict the Outcome Returned from MySQL in Python
import mysql.connector
mydb = mysql.connector.join(
host = "localhost",
consumer = "username",
password = "YoUrPaSsWoRd",
database = "your_database"
)
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM clients LIMIT 10")
myresult = mycursor.fetchall()
for x in myresult:
print(x)
The best way to Begin From One other Place in MySQL from Python
import mysql.connector
mydb = mysql.connector.join(
host = "localhost",
consumer = "username",
password = "YoUrPaSsWoRd",
database = "your_database"
)
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM clients LIMIT 10 OFFSET 5")
myresult = mycursor.fetchall()
for x in myresult:
print(x)