csvSQL is a high-performance Java database engine that bridges the gap between simple flat-file storage and robust relational database management. It enables dynamic schema evolution and full CRUD operations directly on CSV files, providing a lightweight yet powerful solution for localized data management and persistence.
- 🛠️ Full CRUD Operations: Create, Read, Update, and Delete records with ease.
- 📂 Schema Evolution: Dynamically add and drop columns without manual CSV editing.
- 💾 File Persistence: Automatic synchronization between memory and CSV files.
- 🔍 Filtering & Selection: SQL-like
selectmethods with support for column/value filtering. - 📊 Beautiful CLI Display: Built-in automatic table formatting for console visualization.
- ⚡ Lightweight Utility: Core helper methods optimized for array and file operations.
Get csvSQL running in your terminal in under a minute:
-
Clone & Build:
javac -d bin src/items/*.java src/main/*.java src/utility/*.java
-
Run Demo:
java -cp bin main.Main
-
Try the Code:
Table myTable = new Table("employees.csv"); myTable.setTableName("Engineering"); myTable.addColumn("Role"); myTable.insert("Alice", "BackEnd Developer", "Senior"); myTable.display();
The system is designed for modularity and minimal dependencies.
graph LR
A[Main.java] -- "Controls Flow" --> B[Table.java]
B -- "Uses Utility" --> C[Utility.java]
B -- "Sync/Load" --> D[(Data File)]
C -- "File Stats" --> D
style A fill:#000,color:#fff,stroke:#fff,stroke-width:2px
style B fill:#000,color:#fff,stroke:#fff,stroke-width:2px
style C fill:#000,color:#fff,stroke:#fff,stroke-width:2px
style D fill:#333,color:#fff,stroke:#fff,stroke-width:2px
The core data management unit.
| Method | Description | Complexity |
|---|---|---|
addColumn(String name) |
Adds a new column to the table. | O(n) |
dropColumn(String name) |
Removes a column and tilts data. | O(n²) |
insert(String... values) |
Appends a new record. | O(n) |
delete(String col, String val) |
Deletes records matching criteria. | O(n) |
update(String col, String val, String param, String newVal) |
Updates specific record fields. | O(n) |
select() |
Retrieves all data & displays it. | O(n) |
display() |
Formats and prints data to stdout. | O(n²) |
Static helpers for low-level operations.
getRowCount(String file): Efficiently counts file lines.copyArray2D(...): Fast cloning of multidimensional arrays.
// Select records where "Department" is "IT"
String[] filters = {"Department"};
String[] values = {"IT"};
String[][] itStaff = myTable.select(filters, values);csvSQL automatically handles column alignment for you:
---------------------------------
| Name | Role |
---------------------------------
| Alice | Senior Developer |
---------------------------------
- SQL Query Parser: Support for raw string queries (e.g.,
SELECT * FROM table WHERE ...). - Data Typing: Implement type validation (Integer, Double, Date).
- Indexing: Add primary key indexing for O(1) searches.
- Export Options: Support for JSON and XML exports.
Distributed under the MIT License. See LICENSE for more information.
Made with ❤️ by Ali Fuat Akyemis
