Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import MySQLdb
  2. db = MySQLdb.connect(host="127.0.0.1", user="root",passwd="",db="pyex1")
  3.  
  4. # ejecutar consultas: insert, update, delete
  5. cursor = db.cursor()
  6. cursor.execute("insert into person(name,lastname) value('Agustin','Ramos')");
  7. db.commit()
  8.  
  9. # ejecutar consultas select
  10. cursor = db.cursor()
  11. cursor.execute("select * from person");
  12. data=cursor.fetchall()
  13. for d in data:
  14. print "{0} - {1} {2}".format(d[0],d[1],d[2])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement