Software Engineering

Methods to Restrict a MySQL Question in Python

Written by admin


First, you have to the mysql.connector. If you’re not sure of tips on how to get this setup, confer with Methods to Set up MySQL Driver in Python.

Methods to Restrict the End result 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 clients LIMIT 10")
myresult = mycursor.fetchall()

for x in myresult:
  print(x)

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

for x in myresult:
  print(x)

About the author

admin

Leave a Comment