mirror of
https://github.com/simonw/dclient.git
synced 2026-08-06 09:24:12 +02:00
First insert test, using a mock - refs #8
This commit is contained in:
parent
0d4e5cfc73
commit
b204ff56f6
2 changed files with 49 additions and 4 deletions
|
|
@ -7,6 +7,7 @@ from sqlite_utils.utils import rows_from_file, Format, TypeTracker, progressbar
|
|||
import sys
|
||||
from .utils import token_for_url
|
||||
|
||||
|
||||
def get_config_dir():
|
||||
return pathlib.Path(click.get_app_dir("io.datasette.dclient"))
|
||||
|
||||
|
|
@ -182,10 +183,14 @@ def insert(
|
|||
bytes_so_far = 0
|
||||
for batch in _batches(rows, batch_size):
|
||||
if file_size is not None:
|
||||
bytes_consumed_so_far = fp.tell()
|
||||
new_bytes = bytes_consumed_so_far - bytes_so_far
|
||||
bar.update(new_bytes)
|
||||
bytes_so_far += new_bytes
|
||||
try:
|
||||
bytes_consumed_so_far = fp.tell()
|
||||
new_bytes = bytes_consumed_so_far - bytes_so_far
|
||||
bar.update(new_bytes)
|
||||
bytes_so_far += new_bytes
|
||||
except ValueError:
|
||||
# File has likely been closed, so fp.tell() fails
|
||||
pass
|
||||
types = None
|
||||
if first and not no_detect_types:
|
||||
# Detect types on first batch
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue