From c492d419cccb99f60f9bf2a5b540e6d646ded352 Mon Sep 17 00:00:00 2001 From: tswr Date: Wed, 2 Nov 2016 14:28:00 +0300 Subject: [PATCH] Fixing Database class to allow readonly mode --- src/infi/clickhouse_orm/database.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/infi/clickhouse_orm/database.py b/src/infi/clickhouse_orm/database.py index b8e4774..e12c15f 100644 --- a/src/infi/clickhouse_orm/database.py +++ b/src/infi/clickhouse_orm/database.py @@ -18,12 +18,14 @@ class DatabaseException(Exception): class Database(object): - def __init__(self, db_name, db_url='http://localhost:8123/', username=None, password=None): + def __init__(self, db_name, db_url='http://localhost:8123/', username=None, password=None, readonly=False): self.db_name = db_name self.db_url = db_url self.username = username self.password = password - self._send('CREATE DATABASE IF NOT EXISTS `%s`' % db_name) + self.readonly = readonly + if not self.readonly: + self._send('CREATE DATABASE IF NOT EXISTS `%s`' % db_name) def create_table(self, model_class): # TODO check that model has an engine