Skip to content

AliFuatAkyemis/csvSQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

csvSQL Logo

Java Version License Status


🚀 Overview

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.

📑 Table of Contents


✨ Features

  • 🛠️ 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 select methods 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.

🏎️ Quick Start

Get csvSQL running in your terminal in under a minute:

  1. Clone & Build:

    javac -d bin src/items/*.java src/main/*.java src/utility/*.java
  2. Run Demo:

    java -cp bin main.Main
  3. Try the Code:

    Table myTable = new Table("employees.csv");
    myTable.setTableName("Engineering");
    myTable.addColumn("Role");
    myTable.insert("Alice", "BackEnd Developer", "Senior");
    myTable.display();

🏗️ Architecture

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
Loading

📚 API Reference

Table Class

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²)

Utility Class

Static helpers for low-level operations.

  • getRowCount(String file): Efficiently counts file lines.
  • copyArray2D(...): Fast cloning of multidimensional arrays.

💡 Usage Examples

Dynamic Filtering

// Select records where "Department" is "IT"
String[] filters = {"Department"};
String[] values = {"IT"};
String[][] itStaff = myTable.select(filters, values);

Table Representation

csvSQL automatically handles column alignment for you:

---------------------------------
| Name   | Role             |
---------------------------------
| Alice  | Senior Developer |
---------------------------------

🗺️ Roadmap

  • 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.

⚖️ License

Distributed under the MIT License. See LICENSE for more information.


Made with ❤️ by Ali Fuat Akyemis

About

csvSQL is a lightweight Java database engine that provides relational management for CSV files.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors