diff --git a/CHANGELOG.md b/CHANGELOG.md index ca29f7a..173c9d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Change Log Unreleased ---------- - Added `timeout` parameter to database initializer (SUHAR1K) +- Added `verify_ssl_cert` parameter to database initializer - Added `final()` method to querysets (M1hacka) v1.0.3 diff --git a/docs/class_reference.md b/docs/class_reference.md index c30ca9b..c992d8e 100644 --- a/docs/class_reference.md +++ b/docs/class_reference.md @@ -10,7 +10,7 @@ infi.clickhouse_orm.database Database instances connect to a specific ClickHouse database for running queries, inserting data and other operations. -#### Database(db_name, db_url="http://localhost:8123/", username=None, password=None, readonly=False, autocreate=True, timeout=60) +#### Database(db_name, db_url="http://localhost:8123/", username=None, password=None, readonly=False, autocreate=True, timeout=60, verify_ssl_cert=True) Initializes a database instance. Unless it's readonly, the database will be @@ -23,6 +23,7 @@ created on the ClickHouse server if it does not already exist. - `readonly`: use a read-only connection. - `autocreate`: automatically create the database if it does not exist (unless in readonly mode). - `timeout`: the connection timeout in seconds. +- `verify_ssl_cert`: whether to verify the server's certificate when connecting via HTTPS. #### add_setting(name, value) diff --git a/src/infi/clickhouse_orm/database.py b/src/infi/clickhouse_orm/database.py index a3eb85a..06d43ba 100644 --- a/src/infi/clickhouse_orm/database.py +++ b/src/infi/clickhouse_orm/database.py @@ -73,7 +73,8 @@ class Database(object): ''' def __init__(self, db_name, db_url='http://localhost:8123/', - username=None, password=None, readonly=False, autocreate=True, timeout=60): + username=None, password=None, readonly=False, autocreate=True, + timeout=60, verify_ssl_cert=True): ''' Initializes a database instance. Unless it's readonly, the database will be created on the ClickHouse server if it does not already exist. @@ -85,6 +86,7 @@ class Database(object): - `readonly`: use a read-only connection. - `autocreate`: automatically create the database if it does not exist (unless in readonly mode). - `timeout`: the connection timeout in seconds. + - `verify_ssl_cert`: whether to verify the server's certificate when connecting via HTTPS. ''' self.db_name = db_name self.db_url = db_url @@ -93,6 +95,7 @@ class Database(object): self.readonly = False self.timeout = timeout self.request_session = requests.Session() + self.request_session.verify = verify_ssl_cert self.settings = {} self.db_exists = False # this is required before running _is_existing_database self.db_exists = self._is_existing_database()