Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
First, you’ll need the mysql.connector
. In case you are uncertain of the best way to get this setup, confer with How you can 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 = "DELETE FROM clients WHERE tackle = 'The Rockies'"
mycursor.execute(sql)
mydb.commit()
print(mycursor.rowcount, "file(s) deleted")
Specify the injected variable because the second argument to the execute
command as under.
import mysql.connector
mydb = mysql.connector.join(
host = "localhost",
person = "username",
password = "YoUrPaSsWoRd",
database = "your_database"
)
mycursor = mydb.cursor()
sql = "DELETE FROM clients WHERE tackle = %s"
adr = ("The Rockies", )
mycursor.execute(sql, adr)
mydb.commit()
print(mycursor.rowcount, "file(s) deleted")