{"id":21719881,"url":"https://github.com/adielmtz/minidb","last_synced_at":"2026-05-21T14:18:05.272Z","repository":{"id":63276868,"uuid":"539036044","full_name":"adielmtz/MiniDB","owner":"adielmtz","description":"Database engine written in C for study purposes.","archived":false,"fork":false,"pushed_at":"2022-11-19T00:44:04.000Z","size":95,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T21:11:50.975Z","etag":null,"topics":["database"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adielmtz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-20T14:36:28.000Z","updated_at":"2023-02-04T13:24:52.000Z","dependencies_parsed_at":"2022-11-16T06:01:18.031Z","dependency_job_id":null,"html_url":"https://github.com/adielmtz/MiniDB","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adielmtz/MiniDB","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adielmtz%2FMiniDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adielmtz%2FMiniDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adielmtz%2FMiniDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adielmtz%2FMiniDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adielmtz","download_url":"https://codeload.github.com/adielmtz/MiniDB/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adielmtz%2FMiniDB/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33303365,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T12:23:38.849Z","status":"ssl_error","status_checked_at":"2026-05-21T12:22:11.673Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["database"],"created_at":"2024-11-26T01:42:51.528Z","updated_at":"2026-05-21T14:18:05.256Z","avatar_url":"https://github.com/adielmtz.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MiniDB\n\nA small database engine written in C for study purposes.\n\n## File structure\n\n| Offset | Size | Name       | Description                                         |\n|--------|------|------------|-----------------------------------------------------|\n| 0      | 8    | data_size  | The size of each row (data size).                   |\n| 8      | 8    | row_count  | Counts how many rows are stored in the database.    |\n| 16     | 8    | free_count | The number of entries stored in the freelist index. |\n\n## Usage\n\n#### Define a structure\n\n```c\ntypedef struct Human\n{\n    char name[50];\n    int age;\n} Human;\n```\n\n`minidb_create`: Creates a new database file and opens a connection.\n\n```c\nMiniDb db;\nMiniDbState state = minidb_create(\u0026db, \"./mini.db\", sizeof(Human));\n\nif (state != MINIDB_OK) {\n    printf(\"Error: %s\\n\", minidb_error_get_str(state));\n}\n```\n\n`minidb_open`: Opens a connection to an existing database file.\n\n```c\nMiniDb db;\nMiniDbState state = minidb_open(\u0026db, \"./mini.db\");\n\nif (state != MINIDB_OK) {\n    printf(\"Error: %s\\n\", minidb_error_get_str(state));\n}\n```\n\n`minidb_close`: Closes a connection to the database.\n\n```c\nMiniDb db;\nMiniDbState state = minidb_open(\u0026db, \"./mini.db\");\n\nif (state != MINIDB_OK) {\n    printf(\"Error: %s\\n\", minidb_error_get_str(state));\n}\n\nminidb_close(\u0026db);\n```\n\n## Commands\n\n### select\n\n```c\nint64_t key = 1;\nHuman result;\n\nMiniDbState state = minidb_select(\u0026db, key, \u0026result);\nif (state == MINIDB_OK) {\n    printf(\"Name: %s\\n\", result.name);\n    printf(\"Age: %d\\n\", result.age);\n}\n```\n\n### insert\n\n```c\nint64_t key = 1;\nHuman result;\n\nstrncpy(result.name, \"John Doe\", sizeof(result.name));\nresult.age = 20;\n\nMiniDbState state = minidb_insert(\u0026db, key, \u0026result);\nif (state != MINIDB_OK) {\n    printf(\"Error: %s\\n\", minidb_error_get_str(state));\n}\n```\n\n### update\n\n```c\nint64_t key = 1;\nHuman result;\n\nstrncpy(result.name, \"A dragon\", sizeof(result.name));\nresult.age = 5000;\n\nMiniDbState state = minidb_update(\u0026db, key, \u0026result);\nif (state != MINIDB_OK) {\n    printf(\"Error: %s\\n\", minidb_error_get_str(state));\n}\n```\n\n### delete\n\n```c\nint64_t key = 1;\n\nMiniDbState state = minidb_delete(\u0026db, key);\nif (state != MINIDB_OK) {\n    printf(\"Error: %s\\n\", minidb_error_get_str(state));\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadielmtz%2Fminidb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadielmtz%2Fminidb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadielmtz%2Fminidb/lists"}