Import sqlite3 file

is there a way to import a file into a table with a separator ":"?

For example, I have a test.txt file with

value1:result1
value2:result2

want to use something like this in the CLI:

sqlite> .import test.txt table

and in the end I would:

+--------------+
|value1|result1|
+------+-------+
|value2|result2|
+------+-------+
+3
source share
2 answers

use .separator :

.separator STRING      Change separator used by output mode and .import

Here .

+6
source

If you use .help, you may notice something interesting:

sqlite> .help
...
.help                  Show this message
.import FILE TABLE     Import data from FILE into TABLE
...
.separator STRING      Change separator used by output mode and .import
...

So that .importmay be what you are looking for; -)

+3
source

Source: https://habr.com/ru/post/1721155/


All Articles