Move database creation into a separate method

This commit is contained in:
Itai Shirav 2017-01-25 14:40:03 +02:00
parent 48d7dfe661
commit cce85beeef

View File

@ -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)