Fix after review

This commit is contained in:
Понаревский Владимир 2018-05-08 16:41:50 +03:00
parent a5c93dc176
commit 793726adb2

View File

@ -72,8 +72,7 @@ class Database(object):
''' '''
def __init__(self, db_name, db_url='http://localhost:8123/', def __init__(self, db_name, db_url='http://localhost:8123/',
username=None, password=None, readonly=False, autocreate=True, username=None, password=None, readonly=False, autocreate=True):
get_timezone=True):
''' '''
Initializes a database instance. Unless it's readonly, the database will be Initializes a database instance. Unless it's readonly, the database will be
created on the ClickHouse server if it does not already exist. created on the ClickHouse server if it does not already exist.
@ -84,7 +83,6 @@ class Database(object):
- `password`: optional connection credentials. - `password`: optional connection credentials.
- `readonly`: use a read-only connection. - `readonly`: use a read-only connection.
- `autocreate`: automatically create the database if does not exist (unless in readonly mode). - `autocreate`: automatically create the database if does not exist (unless in readonly mode).
- `get_timezone`: automatically detect the server timezone.
''' '''
self.db_name = db_name self.db_name = db_name
self.db_url = db_url self.db_url = db_url
@ -98,9 +96,9 @@ class Database(object):
elif autocreate: elif autocreate:
self.db_exists = False self.db_exists = False
self.create_database() self.create_database()
self.server_timezone = self._get_server_timezone() if get_timezone else pytz.utc
self.server_version = self._get_server_version() self.server_version = self._get_server_version()
# Versions 1.1.53981 and below don't have timezone function
self.server_timezone = self._get_server_timezone() if self.server_version[2] > 53981 else pytz.utc
def create_database(self): def create_database(self):
''' '''