{"id":23629664,"url":"https://github.com/ehtishama/mini-sql","last_synced_at":"2025-11-08T03:30:29.943Z","repository":{"id":268555240,"uuid":"904716156","full_name":"ehtishama/mini-sql","owner":"ehtishama","description":"A simple file-based SQL database implementation in JavaScript. ","archived":false,"fork":false,"pushed_at":"2024-12-17T13:04:25.000Z","size":31,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-28T01:16:29.181Z","etag":null,"topics":["javascript","sql","sqlite"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ehtishama.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-17T12:22:08.000Z","updated_at":"2024-12-17T13:53:01.000Z","dependencies_parsed_at":"2024-12-17T14:19:32.339Z","dependency_job_id":"83e4b0d3-542c-404f-9852-a8144c3423a2","html_url":"https://github.com/ehtishama/mini-sql","commit_stats":null,"previous_names":["ehtishama/mini-sql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehtishama%2Fmini-sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehtishama%2Fmini-sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehtishama%2Fmini-sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehtishama%2Fmini-sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ehtishama","download_url":"https://codeload.github.com/ehtishama/mini-sql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239546894,"owners_count":19657046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","sql","sqlite"],"created_at":"2024-12-28T01:16:35.890Z","updated_at":"2025-11-08T03:30:29.888Z","avatar_url":"https://github.com/ehtishama.png","language":"JavaScript","readme":"\u003e ⚠️ **Warning**\n\u003e \n\u003e It's a fun project meant for learning and exploration!\n\u003e \n\u003e This project was built following a Global Hack Week tutorial by [@utk09-NCL](https://github.com/utk09-NCL).\n\u003e Original code can be found [here](https://github.com/utk09-NCL/mini-sql-db) and tutorial videos can be accessed [here](https://www.youtube.com/watch?v=Cysrhs6uxGo\u0026list=PLPDgudJ_VDUf_lp8RB1ukFQj6UZumKQqA).  \n\n\n# mini-sql\n\nA simple file-based SQL database in JavaScript. It uses SQL like syntax for querying and managing data.\n\n## Folder Structure\n\n```plaintext\nmini-sql-db/\n|--- lib/\n| |--- storage.js # Create JSON files to store data and run read/write operations\n| |--- schema.js # Table schema management and validation\n| |--- query.js # Query parsing and execution\n| |--- indexing.js # Implements indexing and search operation\n| |--- backup.js # Database backup and restoration\n| |--- mutext.js # Mutext Class\n| |--- locks.js # Performs operation on table with locks\n|--- logger/\n| |--- logger.js # Logging utilities\n|--- test/\n| |--- test_db.js # unit tests\n|--- index.js\n|--- package.json\n|--- README.md\n```\n\n## Setup\n\n- Clone the project\n- Run `npm install` inside the project directory\n- Create `.env` file at the root\n- Copy `.env.example` over to `.env`file\n- Update the `MINI_SQL_DB_PATH` path in the `.env` file\n\n## Test\n\n- Run `node test/test_db.js` # This is the test file for all the lib functions.\n\n### Test Sample Output\n\n```bash\n[16 Dec 2024, 16:08:20.626] [SUCCESS] Table \"users\" created successfully\n[16 Dec 2024, 16:08:20.638] [TEST] Table creation test passed.\n\n[16 Dec 2024, 16:08:20.640] [SUCCESS] New row inserted into users successfully\n[16 Dec 2024, 16:08:20.641] [SUCCESS] New row inserted into users successfully\n[16 Dec 2024, 16:08:20.642] [SUCCESS] New row inserted into users successfully\n[16 Dec 2024, 16:08:20.642] [SUCCESS] New row inserted into users successfully\n[16 Dec 2024, 16:08:20.643] [SUCCESS] New row inserted into users successfully\n[16 Dec 2024, 16:08:20.644] [SUCCESS] New row inserted into users successfully\n[16 Dec 2024, 16:08:20.645] [TEST] Insert Into test passed.\n\n┌─────────┬───────┬─────────┐\n│ (index) │ id    │ name    │\n├─────────┼───────┼─────────┤\n│ 0       │ '101' │ 'Alice' │\n│ 1       │ '102' │ 'BOB'   │\n│ 2       │ '103' │ 'John'  │\n│ 3       │ '104' │ 'Tom'   │\n│ 4       │ '105' │ 'MLH'   │\n│ 5       │ '106' │ 'GHW'   │\n└─────────┴───────┴─────────┘\n[16 Dec 2024, 16:08:20.648] [SUCCESS] Select query executed successfully.\n┌─────────┬───────┬─────────┬──────┬─────────┐\n│ (index) │ id    │ name    │ age  │ student │\n├─────────┼───────┼─────────┼──────┼─────────┤\n│ 0       │ '101' │ 'Alice' │ '22' │ 'true'  │\n│ 1       │ '102' │ 'BOB'   │ '25' │ 'true'  │\n│ 2       │ '103' │ 'John'  │ '32' │ 'false' │\n│ 3       │ '104' │ 'Tom'   │ '28' │ 'true'  │\n│ 4       │ '105' │ 'MLH'   │ '10' │ 'false' │\n│ 5       │ '106' │ 'GHW'   │ '10' │ 'false' │\n└─────────┴───────┴─────────┴──────┴─────────┘\n[16 Dec 2024, 16:08:20.652] [SUCCESS] Select query executed successfully.\n[16 Dec 2024, 16:08:20.652] [TEST] Select query test passed.\n\n[16 Dec 2024, 16:08:20.654] [SUCCESS] Index created on column: \"name\" of table \"users\"\n[16 Dec 2024, 16:08:20.655] [SUCCESS] Index created on column: \"age\" of table \"users\"\n[16 Dec 2024, 16:08:20.655] [TEST] Create index test passed\n\n[16 Dec 2024, 16:08:20.657] [INFO] Found 1 matches for John in table users\n┌─────────┬───────┬────────┬──────┬─────────┐\n│ (index) │ id    │ name   │ age  │ student │\n├─────────┼───────┼────────┼──────┼─────────┤\n│ 0       │ '103' │ 'John' │ '32' │ 'false' │\n└─────────┴───────┴────────┴──────┴─────────┘\n[16 Dec 2024, 16:08:20.659] [INFO] Found 2 matches for 10 in table users\n┌─────────┬───────┬───────┬──────┬─────────┐\n│ (index) │ id    │ name  │ age  │ student │\n├─────────┼───────┼───────┼──────┼─────────┤\n│ 0       │ '105' │ 'MLH' │ '10' │ 'false' │\n│ 1       │ '106' │ 'GHW' │ '10' │ 'false' │\n└─────────┴───────┴───────┴──────┴─────────┘\n[16 Dec 2024, 16:08:20.661] [TEST] Search with index test passed\n\n[16 Dec 2024, 16:08:20.667] [SUCCESS] Database backup completed. The backup is available at ./backup.\n[16 Dec 2024, 16:08:20.667] [TEST] Database backup test passed\n\n[16 Dec 2024, 16:08:20.670] [SUCCESS] Database successfully restored from the backup at ./backup.\n[16 Dec 2024, 16:08:20.671] [TEST] Database restore test passed\n\n[16 Dec 2024, 16:08:20.671] [INFO] [Lock] Mutex created for table \"users\"\n[16 Dec 2024, 16:08:20.672] [DEBUG] [Mutex] Lock acquired.\n[16 Dec 2024, 16:08:20.672] [DEBUG] [Mutex] Lock busy, request queued.\n[16 Dec 2024, 16:08:20.673] [INFO] [Lock] Lock acquired for the table \"users\"\n[16 Dec 2024, 16:08:20.673] [INFO] [Lock] Performing operation on table \"users\"\n[16 Dec 2024, 16:08:20.673] [TEST] Task 1 started.\n[16 Dec 2024, 16:08:20.674] [SUCCESS] New row inserted into users successfully\n[16 Dec 2024, 16:08:20.675] [TEST] Task 1 completed.\n[16 Dec 2024, 16:08:20.676] [DEBUG] [MUTEX] Passing the lock to the next function in the queue.\n[16 Dec 2024, 16:08:20.676] [DEBUG] [Mutex] Lock acquired.\n[16 Dec 2024, 16:08:20.677] [INFO] [Lock] Lock released for table \"users\"\n[16 Dec 2024, 16:08:20.677] [INFO] [Lock] Lock acquired for the table \"users\"\n[16 Dec 2024, 16:08:20.678] [INFO] [Lock] Performing operation on table \"users\"\n[16 Dec 2024, 16:08:20.678] [TEST] Task 2 started.\n[16 Dec 2024, 16:08:20.679] [SUCCESS] New row inserted into users successfully\n[16 Dec 2024, 16:08:20.690] [TEST] Task 2 completed.\n[16 Dec 2024, 16:08:20.691] [DEBUG] [Mutex] Lock released.\n[16 Dec 2024, 16:08:20.691] [INFO] [Lock] Lock released for table \"users\"\n[16 Dec 2024, 16:08:20.692] [TEST] Locks test passed.\n┌─────────┬─────────────┐\n│ (index) │ total_users │\n├─────────┼─────────────┤\n│ 0       │ 8           │\n└─────────┴─────────────┘\n[16 Dec 2024, 16:08:20.694] [SUCCESS] Select query executed successfully.\n[16 Dec 2024, 16:08:20.695] [TEST] Aggregation test for \"total_users\" passed\n\n┌─────────┬───────────┐\n│ (index) │ age_count │\n├─────────┼───────────┤\n│ 0       │ 8         │\n└─────────┴───────────┘\n[16 Dec 2024, 16:08:20.697] [SUCCESS] Select query executed successfully.\n[16 Dec 2024, 16:08:20.697] [TEST] Aggregation test for \"age_count\" passed\n\n┌─────────┬─────────────┐\n│ (index) │ average_age │\n├─────────┼─────────────┤\n│ 0       │ 22.375      │\n└─────────┴─────────────┘\n[16 Dec 2024, 16:08:20.699] [SUCCESS] Select query executed successfully.\n[16 Dec 2024, 16:08:20.699] [TEST] Aggregation test for \"average_age\" passed\n\n┌─────────┬──────────────────────────┐\n│ (index) │ average_age_more_than_10 │\n├─────────┼──────────────────────────┤\n│ 0       │ 26.5                     │\n└─────────┴──────────────────────────┘\n[16 Dec 2024, 16:08:20.701] [SUCCESS] Select query executed successfully.\n[16 Dec 2024, 16:08:20.702] [TEST] Aggregation test for \"average_age_more_than_10\" passed\n\n[16 Dec 2024, 16:08:20.703] [TEST] Aggregation tests passed\n```\n\n### Example Usage\n\n```javascript\nimport { createTable, insertInto } from \"mini-sql-db\";\n\ncreateTable(\"CREATE TABLE products (id int, name txt, quantity int)\");\ninsertInto(\"INSERT INTO products (id, name, quantity) VALUES (101, 'Apple', 10)\");\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehtishama%2Fmini-sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehtishama%2Fmini-sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehtishama%2Fmini-sql/lists"}