Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
First, you have to the mysql.connector
. In case you are not sure of find out how to get this setup, seek advice from The right way to Set up MySQL Driver in Python.
import mysql.connector
mydb = mysql.connector.join(
host = "localhost",
person = "username",
password = "YoUrPaSsWoRd",
database = "your_database"
)
mycursor = mydb.cursor()
sql = "SELECT * FROM prospects ORDER BY identify"
mycursor.execute(sql)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
You’ll be able to change the order of the kind by merely setting the order path.
By default, it’s set to ORDER BY <column_name> ASC
, which units the response in ascending order.
If you wish to change it, you merely exchange the ASC
with DESC
as follows:
import mysql.connector
mydb = mysql.connector.join(
host = "localhost",
person = "username",
password = "YoUrPaSsWoRd",
database = "your_database"
)
mycursor = mydb.cursor()
sql = "SELECT * FROM prospects ORDER BY identify DESC"
mycursor.execute(sql)
myresult = mycursor.fetchall()
for x in myresult:
print(x)