dbcli / litecli

CLI for SQLite Databases with auto-completion and syntax highlighting
https://litecli.com
BSD 3-Clause "New" or "Revised" License
2.12k stars 68 forks source link

Add .import command #79

Closed zzl0 closed 4 years ago

zzl0 commented 4 years ago

Description

Add .import command (fix #77).

Checklist

Example

litecli_import

$ cat data.csv
t1 11
t2 22
ex1.db> .schema tbl1
+--------------------------------------------------+
| sql                                              |
+--------------------------------------------------+
| CREATE TABLE tbl1(one varchar(10), two smallint) |
+--------------------------------------------------+
Time: 0.012s

ex1.db> select * from tbl1;
0 rows in set
Time: 0.000s

ex1.db> .import ./data.csv tbl1;
Inserted 2 rows into tbl1
Time: 0.007s

ex1.db> select * from tbl1;
+-----+-----+
| one | two |
+-----+-----+
| t1  | 11  |
| t2  | 22  |
+-----+-----+
2 rows in set
Time: 0.011s
codecov-io commented 4 years ago

Codecov Report

Merging #79 into master will increase coverage by 0.5%. The diff coverage is 87.17%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #79     +/-   ##
=========================================
+ Coverage    67.3%   67.81%   +0.5%     
=========================================
  Files          21       21             
  Lines        1355     1392     +37     
=========================================
+ Hits          912      944     +32     
- Misses        443      448      +5
Impacted Files Coverage Δ
litecli/packages/completion_engine.py 88.41% <100%> (+0.59%) :arrow_up:
litecli/packages/special/dbcommands.py 33.08% <83.33%> (+13.85%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update cd5d4e0...6f450ff. Read the comment docs.

amjith commented 4 years ago

Would it be possible to add a test case for this?

zzl0 commented 4 years ago

Would it be possible to add a test case for this?

Yes, I think it's possible.

I checked the existing test_dbspecial file and previous PR. So I thought we normally don't test the functionality of special command.

I will add tests in next revision.

amjith commented 4 years ago

:+1: