mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-29 04:03:44 +03:00
Fixed bug with StringIO import, incompatible with python 3
This commit is contained in:
parent
9bca42fe7e
commit
76718426bf
|
@ -50,7 +50,7 @@ class Database(object):
|
|||
|
||||
def insert(self, model_instances, batch_size=1000):
|
||||
from six import next
|
||||
from cStringIO import StringIO
|
||||
from io import BytesIO
|
||||
i = iter(model_instances)
|
||||
try:
|
||||
first_instance = next(i)
|
||||
|
@ -62,7 +62,7 @@ class Database(object):
|
|||
raise DatabaseException("You can't insert into read only table")
|
||||
|
||||
def gen():
|
||||
buf = StringIO()
|
||||
buf = BytesIO()
|
||||
buf.write(self._substitute('INSERT INTO $table FORMAT TabSeparated\n', model_class).encode('utf-8'))
|
||||
first_instance.set_database(self)
|
||||
buf.write(first_instance.to_tsv(include_readonly=False).encode('utf-8'))
|
||||
|
@ -78,7 +78,7 @@ class Database(object):
|
|||
# Return the current batch of lines
|
||||
yield buf.getvalue()
|
||||
# Start a new batch
|
||||
buf = StringIO()
|
||||
buf = BytesIO()
|
||||
lines = 0
|
||||
# Return any remaining lines in partial batch
|
||||
if lines:
|
||||
|
|
Loading…
Reference in New Issue
Block a user