mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-28 19:53:44 +03:00
Send readonly=1 when database is created in readonly mode
This commit is contained in:
parent
f22073e2e6
commit
5b03e66048
|
@ -146,6 +146,8 @@ class Database(object):
|
|||
params['user'] = self.username
|
||||
if self.password:
|
||||
params['password'] = self.password
|
||||
if self.readonly:
|
||||
params['readonly'] = '1'
|
||||
return params
|
||||
|
||||
def _substitute(self, query, model_class=None):
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import unittest
|
||||
|
||||
from infi.clickhouse_orm.database import Database
|
||||
from infi.clickhouse_orm.database import Database, DatabaseException
|
||||
from infi.clickhouse_orm.models import Model
|
||||
from infi.clickhouse_orm.fields import *
|
||||
from infi.clickhouse_orm.engines import *
|
||||
|
@ -117,6 +117,18 @@ class DatabaseTestCase(unittest.TestCase):
|
|||
p = list(self.database.select("SELECT * from $table", Person))[0]
|
||||
self.assertEquals(p.first_name, s)
|
||||
|
||||
def test_readonly(self):
|
||||
orig_database = self.database
|
||||
self.database = Database(orig_database.db_name, readonly=True)
|
||||
with self.assertRaises(DatabaseException):
|
||||
self._insert_and_check(self._sample_data(), len(data))
|
||||
self.assertEquals(self.database.count(Person), 0)
|
||||
with self.assertRaises(DatabaseException):
|
||||
self.database.drop_table(Person)
|
||||
with self.assertRaises(DatabaseException):
|
||||
self.database.drop_database()
|
||||
self.database = orig_database
|
||||
|
||||
def _sample_data(self):
|
||||
for entry in data:
|
||||
yield Person(**entry)
|
||||
|
|
Loading…
Reference in New Issue
Block a user