db=MySQLdb.connect(host='localhost',user='root',passwd='123',db='08day5') cur=db.cursor(cursorclass=MySQLdb.cursors.DictCursor) cur.execute('DROP TABLE IF EXISTS EMPLOYEE') sql='''CREATE TABLE EMPLOYEE( id INT PRIMARY KEY AUTO_INCREMENT, first_name VARCHAR(20) NOT NULL, sql='''INSERT INTO EMPLOYEE(first_name,last_name,age,sex,income) values('xiaoqing','zhang',20,'W',2400)''' sql="INSERT INTO EMPLOYEE(first_name,last_name,\ VALUES('%s','%s','%d','%c','%f')" % \ ('wuji','zhang',34,'M',3400.8) print 'there is some error!' sql="SELECT * FROM EMPLOYEE WHERE income > '%d'" % (1000) print 'there is some error!' sql="UPDATE EMPLOYEE SET AGE=AGE+1 WHERE SEX='%c'" % ('M') sql="DELETE FROM EMPLOYEE WHERE age>'%d'" % (20)
|