Skip to content

Instantly share code, notes, and snippets.

@evilnapsis
Created July 29, 2016 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evilnapsis/954c840a7db4f24f1a93e1ee2d1a9b6b to your computer and use it in GitHub Desktop.
Save evilnapsis/954c840a7db4f24f1a93e1ee2d1a9b6b to your computer and use it in GitHub Desktop.
import MySQLdb
db = MySQLdb.connect(host="127.0.0.1", user="root",passwd="",db="pyex1")
# ejecutar consultas: insert, update, delete
cursor = db.cursor()
cursor.execute("insert into person(name,lastname) value('Agustin','Ramos')");
db.commit()
# ejecutar consultas select
cursor = db.cursor()
cursor.execute("select * from person");
data=cursor.fetchall()
for d in data:
print "{0} - {1} {2}".format(d[0],d[1],d[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment