From cce85beeef2123520e1d095cfbd90cf7955697e8 Mon Sep 17 00:00:00 2001 From: Itai Shirav Date: Wed, 25 Jan 2017 14:40:03 +0200 Subject: [PATCH] Move database creation into a separate method --- src/infi/clickhouse_orm/database.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/infi/clickhouse_orm/database.py b/src/infi/clickhouse_orm/database.py index e12c15f..327077a 100644 --- a/src/infi/clickhouse_orm/database.py +++ b/src/infi/clickhouse_orm/database.py @@ -25,7 +25,13 @@ class Database(object): self.password = password self.readonly = readonly if not self.readonly: - self._send('CREATE DATABASE IF NOT EXISTS `%s`' % db_name) + self.create_database() + + def create_database(self): + self._send('CREATE DATABASE IF NOT EXISTS `%s`' % self.db_name) + + def drop_database(self): + self._send('DROP DATABASE `%s`' % self.db_name) def create_table(self, model_class): # TODO check that model has an engine @@ -34,9 +40,6 @@ class Database(object): def drop_table(self, model_class): self._send(model_class.drop_table_sql(self.db_name)) - def drop_database(self): - self._send('DROP DATABASE `%s`' % self.db_name) - def insert(self, model_instances, batch_size=1000): from six import next i = iter(model_instances)