Skip to content

Commit

Permalink
Max/write file 2 (#25)
Browse files Browse the repository at this point in the history
* Write_file accepts file argument

* Remote prints

* Avoid file delete

* Make sure we don't delete user's file
  • Loading branch information
max-hoffman authored Aug 4, 2021
1 parent c9ed25c commit f5a60d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doltcli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ def _import_helper(
fname = tempfile.mktemp(suffix=".csv")
import_flags = IMPORT_MODES_TO_FLAGS[import_mode]
try:
fname = write_import_file(fname)
import_file = write_import_file(fname)
args = ["table", "import", table] + import_flags
if primary_key:
args += ["--pk={}".format(",".join(primary_key))]
if do_continue is True:
args += ["--continue"]

dolt.execute(args + [fname])
dolt.execute(args + [import_file])

if commit:
msg = commit_message or f"Committing write to table {table} in {import_mode} mode"
Expand Down
3 changes: 3 additions & 0 deletions tests/test_write.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import pytest

from doltcli import (
Expand Down Expand Up @@ -100,6 +102,7 @@ def test_write_file(init_empty_test_repo, tmp_path):
primary_key=["id"],
do_continue=True,
)
assert os.path.exists(tmp_path)
actual = read_rows(dolt, "characters")
compare_rows_helper(TEST_ROWS[:2], actual)

Expand Down

0 comments on commit f5a60d8

Please sign in to comment.