/ Published in: Python

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import MySQLdb import MySQLdb.cursors class zenMySql(): def __init__(self, host, user, password, db): self.host = host self.user = user self.passwd = password self.db = db def __del__(self): self.conn.close() def dbConnect(self): self.conn = MySQLdb.connect(host=self.host, user=self.user, \ passwd=self.passwd, db=self.db, cursorclass = MySQLdb.cursors.DictCursor) self.cur = self.conn.cursor() def executeQuery(self, query): rowDump = [] self.cur.execute(query) for row in self.cur: rowDump.append(row) return rowDump
Comments
