Replies: 2 comments 3 replies
-
Hi Hrvoje SQLite does not allow stored procedures and has no statement like LOAD DATA INFILE. However, there are at least two options for bulk import of CSV data. Within SQLiteStudioYou can use the SQLiteStudio import() function to achieve this. Create a SELECT statement similar to this for each CSV file you want to import: SELECT import('/home/user/sample_tab.csv', 'CSV', 'myTable', 'UTF-8', 'CsvImport.FirstRowAsColumns=true
CsvImport.Separator=4
CsvImport.CustomSeparator=|'); Parameters need to be set as follows:
When creating the instructions it might be helpful to do this in a good text editor (e.g Notepad++) that gives better support for dealing with larger amounts of text. Once you have everything you need you can save these instructions as SQL file, load it in SQLiteStudio's SQL editor in and execute it from there. Without SQLiteStudio using the command promptAnother option might be to use the scripting capability of SQLite. To do this, create a file like the following: -- open database
.open /home/user/sqlittest.db
.mode csv
-- first parameter is the column separator, second parameter is the line/record separator
.separator "|" "\r\n"
-- add lines below as needed
-- first parameter is path to CSV, second parameter is the table name
.import /home/user/Desktop/sample_01.csv myTable_01
.import /home/user/Desktop/sample_02.csv myTable_02
-- exit SQLite
.quit When you save this script as import.txt you can run it by calling With both methods the table will be created in case it does not exist; otherwise data will be appended. I appreciate SQLiteStudio very much for evaluating data and testing SQL statements. However, for bulk import/export I prefer the command prompt method because the instructions are much easier to create with a little help from Excel/Calc and some regex magic ;-) Hope this helps, |
Beta Was this translation helpful? Give feedback.
-
Note of caution - when using the csv import I chose the pipe "|" as my field separator. |
Beta Was this translation helpful? Give feedback.
-
Hello,
First of all, let me tell that SQLiteStudio is great application and I really like it.
I'm using Import tool a lot. I have data available in CSV which I import into SQLiteStudio.
Since I have quite a lot of this CSV files it takes me some time until I import all I need.
So it would be perfect if I could somehow automate this.
Is it possible to automate the import task somehow (stored procedure, batch/cmd script, ...) ?
Thanks,
Hrvoje
Beta Was this translation helpful? Give feedback.
All reactions