def getDBConnection(host, usr, pwd, db, cursor_type="normal"): db_connect = None db_cursor = None try: if cursor_type == "dict": db_connect = MySQLdb.connect(host, usr, pwd, db, cursorclass=MySQLdb.cursors.DictCursor) else: db_connect = MySQLdb.connect(host, usr, pwd, db) db_connect.set_character_set('utf8') db_cursor = db_connect.cursor() except Exception, msg: getLogger().error("getDBCursor() Failed : %s"%msg)
def __init__(self, _cursor=None): self.cursor = _cursor self.logger = getLogger()