The way to Restrict a MySQL Question in Python


First, you will want the mysql.connector. If you’re uncertain of how you can get this setup, seek advice from The way to Set up MySQL Driver in Python.

The way to Restrict the Consequence 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 prospects LIMIT 10")
myresult = mycursor.fetchall()

for x in myresult:
  print(x)

The 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 prospects LIMIT 10 OFFSET 5")
myresult = mycursor.fetchall()

for x in myresult:
  print(x)

Leave a Reply