Skip to content

Instantly share code, notes, and snippets.



Created Jul 31, 2009
What would you like to do?
class DBCursor(MySQLdb.cursors.DictCursor):
def lock_on_string(self, str, timeout=1000):
self.execute('select get_lock(%s, %s);', (str, timeout))
return self.fetchone()
def unlock_on_string(str, timeout=1000):
self.execute('select release_lock(%s);', (str,))
return self.fetchone()
def instantiate(*args, **kargs):
# fixme: use ConfigFile to load connection info
conn = MySQLdb.connect(host='localhost', user='root', passwd='', db='amp')
cursor = conn.cursor(DBCursor)
setattr(cursor, 'conn', conn)
cursor.execute('set names utf8;')
cursor.execute('set character set utf8;')
cursor.execute('set character_set_connection = utf8;')
return cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.