Share My Creation Csv to SQLite program

Attached you find a small project to convert csv files to a SQLite database.
The program:
- detects automatically between the two separator characters ',' ';'.
- determines, on request, the data type for each column (TEXT, REAL, INREGER), these can be changed.
- the column names are the values of the first line in the csv file.
- three test csv files are included.
- by default, the Database generic file name is the same as the csv file name.
- by default, the Table name is also the same as the csv file name, but empty characters are automatically removed and "-" (minus) characters are replaced by "_" (underscore).

1667305784793.png


EDIT: 2022.11.01 Version 1.4
Removed invalid characters in Table names.
Added: Number of rows / Time to load csv / Time to convert.
The CsvToSQLiteExe file is still the old file, a new file with Java 11 is too big.
I left also the previous version zip file.

EDIT: 2021.09.18
Added the use of SQLite transaction, suggested by Diceman in post #6.

EDIT: 2021.01.29
Added an exe file:
CsvToSQLiteExe.zip
You need to unzip it to get the exe file.
Unfortunately the exe file is not accepted by my McAfee anti virus program it is put in quarantaine.
I must manually exclude from the analysis.
 

Attachments

  • CsvToSQLiteV1_2.zip
    5.4 KB · Views: 303
  • CsvToSQLiteExe.zip
    7.3 KB · Views: 69
  • CsvToSQLite_V1_4.zip
    12.9 KB · Views: 91
Last edited:

rboeck

Well-Known Member
Licensed User
Longtime User
Last week i found a wonderfull program, which is able to connect and migrate all most used databases against another; its include Access, Excel, dBase, Foxpro, Firebird, SQL Server, Sqlite, PostgreSql, ODBC, OLEDB and much more.
Its a matter minutes to transfer an access table to an sqlite db and back. Also text files are supported. Even the free version is very usefull.
Link: http://fishcodelib.com/DBMigration.htm
 

Diceman

Active Member
Licensed User
Klaus,

Very nice utility. :)

As a suggestion (no rush) you might want to wrap the table inserts in a transaction (with Try/Catch block) because it will run 20x faster. I did that with your program and it is now fast as lightning. If it throws an exception you should report the record# and the record contents on the screen so the user knows which CSV rcd caused the problem. In my case I roll back the transaction. I suppose you could also have an option (checkbox) to continue with the inserts even if there are exceptions.
 

klaus

Expert
Licensed User
Longtime User
Hi Diceman.
I saw your post only today, do not know why I missed it.

I added your suggestion to use SQLite transaction. Yes the program is now very fast.

The project has been updated to version 1.2 in the first post.
 

Mashiane

Expert
Licensed User
Longtime User
Last week i found a wonderfull program, which is able to connect and migrate all most used databases against another; its include Access, Excel, dBase, Foxpro, Firebird, SQL Server, Sqlite, PostgreSql, ODBC, OLEDB and much more.
Its a matter minutes to transfer an access table to an sqlite db and back. Also text files are supported. Even the free version is very usefull.
Link: http://fishcodelib.com/DBMigration.htm
Their tools have been my favorite like forever...
 
Top