Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlite3 file import

Tags:

import

sqlite

is here a way to import a file into table with ":" being the separator?

for example I have file test.txt with

value1:result1
value2:result2

want to use something like this on the CLI:

sqlite> .import test.txt table

and at the end I would have:

+--------------+
|value1|result1|
+------+-------+
|value2|result2|
+------+-------+
like image 390
sqlite3 Avatar asked Nov 24 '25 09:11

sqlite3


2 Answers

use .separator :

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

Here.

like image 70
pierrotlefou Avatar answered Nov 28 '25 16:11

pierrotlefou


If you use .help, you might 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, .import might be what you are searching for ;-)

like image 45
Pascal MARTIN Avatar answered Nov 28 '25 17:11

Pascal MARTIN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!