Merge pull request #7 from tswr/master

Fixing Database class to allow readonly mode
This commit is contained in:
ishirav 2016-11-09 17:08:29 +02:00 committed by GitHub
commit 3b82f31ec2

View File

@ -18,11 +18,13 @@ class DatabaseException(Exception):
class Database(object): 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_name = db_name
self.db_url = db_url self.db_url = db_url
self.username = username self.username = username
self.password = password self.password = password
self.readonly = readonly
if not self.readonly:
self._send('CREATE DATABASE IF NOT EXISTS `%s`' % db_name) self._send('CREATE DATABASE IF NOT EXISTS `%s`' % db_name)
def create_table(self, model_class): def create_table(self, model_class):