diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4579012..e933d06 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,10 @@ Change Log ========== +v0.8.2 +------ +- Fix broken Python 3 support (M1hacka) + v0.8.1 ------ - Add support for ReplacingMergeTree (leenr) diff --git a/buildout.cfg b/buildout.cfg index ad10a3e..e3de92a 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -49,6 +49,9 @@ eggs = ${project:name} enum34 infi.unittest infi.traceback + memory_profiler + profilehooks + psutil zc.buildout scripts = ipython nosetests diff --git a/src/infi/clickhouse_orm/database.py b/src/infi/clickhouse_orm/database.py index 7226f82..1103a1b 100644 --- a/src/infi/clickhouse_orm/database.py +++ b/src/infi/clickhouse_orm/database.py @@ -50,35 +50,35 @@ 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) except StopIteration: - return # model_instances is empty + return # model_instances is empty model_class = first_instance.__class__ if first_instance.readonly: 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')) - buf.write('\n') + buf.write('\n'.encode('utf-8')) # Collect lines in batches of batch_size lines = 2 for instance in i: instance.set_database(self) buf.write(instance.to_tsv(include_readonly=False).encode('utf-8')) - buf.write('\n') + buf.write('\n'.encode('utf-8')) lines += 1 if lines >= batch_size: # 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: