Return to Snippet

Revision: 49479
at July 22, 2011 06:00 by eristoddle


Initial Code
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

Initial URL


Initial Description


Initial Title
Python MySQLdb with Dictionary Cursor

Initial Tags


Initial Language
Python