Created
October 10, 2013 05:37
-
-
Save harrifeng/6913541 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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