A lightweight .NET utility that automatically converts CSV files into SQLite databases. It infers column types, generates tables dynamically, and inserts all rows without requiring predefined models.
- 📂 CSV Upload – Accepts any CSV file with headers.
- 🧠 Type Inference – Detects
INTEGER,REAL,BOOLEAN,DATETIME, and falls back toSTRING. - 🗄️ Dynamic Table Creation – Builds SQLite schemas on the fly, based on CSV headers and inferred types.
- 📥 Data Insertion – Inserts rows into SQLite using parameterized SQL.
- ⚡ Generic – Works with any CSV structure, no hardcoding required.
- 📝 Summary Report – Returns a quick overview of detected columns and types.
- .NET 8 SDK
- SQLite (included via
Microsoft.Data.SqliteNuGet package)
Clone the repository:
git clone https://github.com/yourusername/CsvToSqliteMigrationUtility.git
cd CsvToSqliteMigrationUtilityInstall dependencies:
dotnet restoreusing var fileStream = File.OpenRead("books.csv");
var service = new FileProcessingService();
string result = await service.ProcessFileAsync(fileStream, "books.csv");
Console.WriteLine(result);Detected columns in 'books.csv':
Id: INTEGER
Title: STRING
Price: REAL
PublishedOn: DATETIME
IsAvailable: BOOLEAN
A new file named books.db will be created, containing a Books table with all imported data.
- Reads header row → extracts column names.
- Samples first rows → infers types for each column.
- Generates
CREATE TABLESQL → builds schema dynamically. - Reads entire CSV → converts values to proper types.
- Executes
INSERT INTO→ adds rows into SQLite.
Id,Title,Price,PublishedOn,IsAvailable
1,The Hobbit,12.5,1937-09-21,true
2,1984,9.99,1949-06-08,false
3,Brave New World,15.0,1932-01-01,trueMIT License. Feel free to use and modify.