Skip to content

Instantly share code, notes, and snippets.

@harrifeng
Created October 10, 2013 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harrifeng/6913541 to your computer and use it in GitHub Desktop.
Save harrifeng/6913541 to your computer and use it in GitHub Desktop.
class myConnection(torndb.Connection):
"""
In torndb version 0.1, the time zone can not be set. we have to create our own connection class
and reconnect()
"""
def __init__(self, host=None, database=None, user=None, password=None, time_zone="+8:00"):
torndb.Connection.__init__(self, host=host, database=database, user=user, password=password)
self._db_args['init_command'] = ('SET time_zone = "%s"' % time_zone)
try:
self.reconnect()
except Exception:
logging.error("Cannot connect to MySQL on %s", self.host,
exc_info=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment