mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2025-07-25 15:29:50 +03:00
Fixed "TypeError: a bytes-like object is required, not 'str'" on \n insertions
This commit is contained in:
parent
76718426bf
commit
533e6e187a
|
@ -55,7 +55,7 @@ class Database(object):
|
||||||
try:
|
try:
|
||||||
first_instance = next(i)
|
first_instance = next(i)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
return # model_instances is empty
|
return # model_instances is empty
|
||||||
model_class = first_instance.__class__
|
model_class = first_instance.__class__
|
||||||
|
|
||||||
if first_instance.readonly:
|
if first_instance.readonly:
|
||||||
|
@ -66,13 +66,13 @@ class Database(object):
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user