Posted By

magicrebirth on 03/12/10


Tagged

mysql database python mysqldb


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

gartenstuhl
magna


MySQL-Python


 / Published in: Python
 

URL: http://magicrebirth.wordpress.com/2009/08/30/mysql-python-and-apple-osx-10-5-leopard/

  1. import MySQLdb
  2.  
  3. conn = MySQLdb.connect(host=\"localhost\", user=\"root\", passwd=\"nobodyknow\", db=\"amit\")
  4. cursor = conn.cursor()
  5.  
  6. stmt = \"SELECT * FROM overflows\"
  7. cursor.execute(stmt)
  8.  
  9. # Fetch and output
  10. result = cursor.fetchall()
  11. print result
  12.  
  13. # get the number of rows
  14. numrows = int(cursor.rowcount)
  15.  
  16. # Close connection
  17. conn.close()

Report this snippet  

You need to login to post a comment.