From b8fd39c6a6b5fcd5a28a9b757c5164fb447a7a48 Mon Sep 17 00:00:00 2001 From: Itai Shirav Date: Tue, 26 Feb 2019 23:12:32 +0200 Subject: [PATCH] Use HTTP Basic Authentication instead of passing the credentials in the URL --- CHANGELOG.md | 1 + src/infi/clickhouse_orm/database.py | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a784f73..66ce749 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Unreleased - Extend date field range (trthhrtz) - Fix parsing of server errors in ClickHouse v19.3.3+ - Fix pagination when asking for the last page on a query that matches no records +- Use HTTP Basic Authentication instead of passing the credentials in the URL v1.0.4 ------ diff --git a/src/infi/clickhouse_orm/database.py b/src/infi/clickhouse_orm/database.py index f7b6e87..b7379da 100644 --- a/src/infi/clickhouse_orm/database.py +++ b/src/infi/clickhouse_orm/database.py @@ -99,12 +99,12 @@ class Database(object): ''' self.db_name = db_name self.db_url = db_url - self.username = username - self.password = password self.readonly = False self.timeout = timeout self.request_session = requests.Session() self.request_session.verify = verify_ssl_cert + if username: + self.request_session.auth = (username, password or '') self.settings = {} self.db_exists = False # this is required before running _is_existing_database self.db_exists = self._is_existing_database() @@ -345,10 +345,6 @@ class Database(object): params.update(self.settings) if self.db_exists: params['database'] = self.db_name - if self.username: - params['user'] = self.username - if self.password: - params['password'] = self.password # Send the readonly flag, unless the connection is already readonly (to prevent db error) if self.readonly and not self.connection_readonly: params['readonly'] = '1'