"string injection" SQL, , , str(DEPT) , , . API- Python - "SQL-", . ( ).
MySQLdb %s , ( , PEP8, , ;):
conn = MySQLdb.connect(host="localhost", user="user", passwd="pass", db="dbase")
cursor = conn.cursor()
q = 'SELECT * FROM %s WHERE course=%%s AND sec = %%s""" % (DEPT,)
cursor.execute(q, (CLASS, SEC))
%% , q, % , q %s, execute CLASS SEC. str ..
, Python 2.6 , format %, "" % ", . , 2.5 ( Python, ).