mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2025-07-27 00:09:49 +03:00
Finished Release v0.8.2
This commit is contained in:
commit
8f825bc537
|
@ -1,6 +1,10 @@
|
||||||
Change Log
|
Change Log
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
v0.8.2
|
||||||
|
------
|
||||||
|
- Fix broken Python 3 support (M1hacka)
|
||||||
|
|
||||||
v0.8.1
|
v0.8.1
|
||||||
------
|
------
|
||||||
- Add support for ReplacingMergeTree (leenr)
|
- Add support for ReplacingMergeTree (leenr)
|
||||||
|
|
|
@ -49,6 +49,9 @@ eggs = ${project:name}
|
||||||
enum34
|
enum34
|
||||||
infi.unittest
|
infi.unittest
|
||||||
infi.traceback
|
infi.traceback
|
||||||
|
memory_profiler
|
||||||
|
profilehooks
|
||||||
|
psutil
|
||||||
zc.buildout
|
zc.buildout
|
||||||
scripts = ipython
|
scripts = ipython
|
||||||
nosetests
|
nosetests
|
||||||
|
|
|
@ -50,7 +50,7 @@ class Database(object):
|
||||||
|
|
||||||
def insert(self, model_instances, batch_size=1000):
|
def insert(self, model_instances, batch_size=1000):
|
||||||
from six import next
|
from six import next
|
||||||
from cStringIO import StringIO
|
from io import BytesIO
|
||||||
i = iter(model_instances)
|
i = iter(model_instances)
|
||||||
try:
|
try:
|
||||||
first_instance = next(i)
|
first_instance = next(i)
|
||||||
|
@ -62,23 +62,23 @@ class Database(object):
|
||||||
raise DatabaseException("You can't insert into read only table")
|
raise DatabaseException("You can't insert into read only table")
|
||||||
|
|
||||||
def gen():
|
def gen():
|
||||||
buf = StringIO()
|
buf = BytesIO()
|
||||||
buf.write(self._substitute('INSERT INTO $table FORMAT TabSeparated\n', model_class).encode('utf-8'))
|
buf.write(self._substitute('INSERT INTO $table FORMAT TabSeparated\n', model_class).encode('utf-8'))
|
||||||
first_instance.set_database(self)
|
first_instance.set_database(self)
|
||||||
buf.write(first_instance.to_tsv(include_readonly=False).encode('utf-8'))
|
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
|
# Collect lines in batches of batch_size
|
||||||
lines = 2
|
lines = 2
|
||||||
for instance in i:
|
for instance in i:
|
||||||
instance.set_database(self)
|
instance.set_database(self)
|
||||||
buf.write(instance.to_tsv(include_readonly=False).encode('utf-8'))
|
buf.write(instance.to_tsv(include_readonly=False).encode('utf-8'))
|
||||||
buf.write('\n')
|
buf.write('\n'.encode('utf-8'))
|
||||||
lines += 1
|
lines += 1
|
||||||
if lines >= batch_size:
|
if lines >= batch_size:
|
||||||
# Return the current batch of lines
|
# Return the current batch of lines
|
||||||
yield buf.getvalue()
|
yield buf.getvalue()
|
||||||
# Start a new batch
|
# Start a new batch
|
||||||
buf = StringIO()
|
buf = BytesIO()
|
||||||
lines = 0
|
lines = 0
|
||||||
# Return any remaining lines in partial batch
|
# Return any remaining lines in partial batch
|
||||||
if lines:
|
if lines:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user