How one can Restrict a MySQL Question in Python


First, you will want the mysql.connector. In case you are uncertain of easy methods to get this setup, confer with How one can Set up MySQL Driver in Python.

How one can Restrict the Outcome Returned from MySQL in Python

import mysql.connector

mydb = mysql.connector.join(
  host = "localhost",
  person = "username",
  password = "YoUrPaSsWoRd",
  database = "your_database"
)

mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM prospects LIMIT 10")
myresult = mycursor.fetchall()

for x in myresult:
  print(x)

How one can Begin From One other Place in MySQL from Python

import mysql.connector

mydb = mysql.connector.join(
  host = "localhost",
  person = "username",
  password = "YoUrPaSsWoRd",
  database = "your_database"
)

mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM prospects LIMIT 10 OFFSET 5")
myresult = mycursor.fetchall()

for x in myresult:
  print(x)

Leave a Reply