import MySQLdb db= MySQLdb.connect(host="localhost", user="python-test", passwd="python", db="python-test") cursor = db.cursor() stmt = "SELECT * from books" cursor.execute(stmt) rows = cursor.fetchall () for row in rows: print "Row: " for col in row : print "Column: %s" % (col) print "End of Row" print "Number of rows returned: %d" % cursor.rowcount cursor.close() db.close()
Wednesday, September 12, 2012
Reading Data from MySQL Database | Python Example
Subscribe to:
Post Comments (Atom)