Page 93 - PYTHON-12
P. 93

Inserting a record in ‘emp’

                   import MySQLdb

                   db1 = MySQLdb.connect("localhost","root","","TESTDB" )


                   cursor = db1.cursor()

                   # Prepareing SQL statement to insert one record with the given values

                   sql = "INSERT INTO EMP VALUES (1,'ANIL KUMAR',86000);"


                   try:

                      cursor.execute(sql)

                      db1.commit()
   88   89   90   91   92   93   94   95   96   97   98