This is my script using MySQLdb with python3.6
import MySQLdb
# start connection
db = MySQLdb.connect("localhost", "root", "asdf", "projecten")
# create cursor
c = db.cursor()
# insert multiple records using a tuple
cities = [
('Boston', 'MA', 600000),
('Chicago', 'IL', 2700000),
('Houston', 'TX', 2100000),
('Phoenix', 'AZ', 1500000)
]
# sql statement
sql = "INSERT INTO projecten.population(city, state, population) VALUES(%s, %s, %s)"
# insert data into table with list cities
c.executemany(sql, cities)
# commit changes
db.commit()
# close connection
db.close()
Is this safe against sql injections because some people use ? instead of %s but on python3.6 that is not working