{"id":25516280,"url":"https://github.com/fl1yd/lightdb","last_synced_at":"2025-06-24T10:35:43.345Z","repository":{"id":37098803,"uuid":"404610048","full_name":"Fl1yd/LightDB","owner":"Fl1yd","description":"Lightweight JSON Database for Python","archived":false,"fork":false,"pushed_at":"2024-07-07T10:43:52.000Z","size":69,"stargazers_count":29,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T20:46:54.232Z","etag":null,"topics":["database","dbms","lightdb","lightweight-database","orm","python"],"latest_commit_sha":null,"homepage":"https://lightdb.readthedocs.io","language":"Python","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/Fl1yd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2021-09-09T06:25:06.000Z","updated_at":"2025-04-10T04:33:42.000Z","dependencies_parsed_at":"2025-04-10T20:35:44.518Z","dependency_job_id":"f7ced045-d0cf-4f99-b810-c1dae18e61bd","html_url":"https://github.com/Fl1yd/LightDB","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/Fl1yd/LightDB","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fl1yd%2FLightDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fl1yd%2FLightDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fl1yd%2FLightDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fl1yd%2FLightDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fl1yd","download_url":"https://codeload.github.com/Fl1yd/LightDB/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fl1yd%2FLightDB/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261652620,"owners_count":23190296,"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":["database","dbms","lightdb","lightweight-database","orm","python"],"created_at":"2025-02-19T14:19:58.523Z","updated_at":"2025-06-24T10:35:43.299Z","avatar_url":"https://github.com/Fl1yd.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"docs\\source\\_static\\logo_light.svg\"\u003e\n    \u003cbr\u003e\n    \u003cb\u003eLightDB\u003c/b\u003e: Lightweight JSON Database for Python\n\u003c/p\u003e\n\n\n\u003ch1\u003eWhat is this?\u003c/h1\u003e\n\nLightDB is a simple and lightweight JSON database for Python that allows users to \u003cb\u003eefficiently\u003c/b\u003e write data to a file. It is designed to be \u003cb\u003eeasy to use\u003c/b\u003e, making it a great choice for developers who need a fast and reliable way to store and retrieve data.\n\n\n\u003ch1\u003eInstalling\u003c/h1\u003e\n\nYou can install LightDB using \u003ccode\u003epip\u003c/code\u003e:\n\n\u003cpre lang=\"bash\"\u003e\npip install LightDB\n\u003c/pre\u003e\n\n\n\u003ch1\u003eUsage\u003c/h1\u003e\n\nTo use LightDB, first import the \u003ccode\u003eLightDB\u003c/code\u003e class from the \u003ccode\u003elightdb\u003c/code\u003e package:\n\n\u003cpre lang=\"python\"\u003e\nfrom lightdb import LightDB\n\u003c/pre\u003e\n\nThen, create a \u003ccode\u003eLightDB\u003c/code\u003e object by passing in the path to a JSON file where the database will be stored:\n\n\u003cpre lang=\"python\"\u003e\ndb = LightDB(\"db.json\")\n\u003c/pre\u003e\n\nYou can then set key-value pairs in the database using the \u003ccode\u003eset()\u003c/code\u003e method:\n\n\u003cpre lang=\"python\"\u003e\ndb.set(\"name\", \"Alice\")\ndb.set(\"age\", 30)\n\u003c/pre\u003e\n\nTo save the changes, use the \u003ccode\u003esave()\u003c/code\u003e method:\n\n\u003cpre lang=\"python\"\u003e\ndb.save()\n\u003c/pre\u003e\n\n\n\u003ch1\u003eUsing Models\u003c/h1\u003e\n\nLightDB supports defining models for more structured and convenient data management. Here’s how to use models with LightDB:\n\nFirst, import the necessary classes:\n\n\u003cpre lang=\"python\"\u003e\nfrom typing import List, Dict, Any\n\nfrom lightdb import LightDB\nfrom lightdb.models import Model\n\u003c/pre\u003e\n\nDefine your model by extending the \u003ccode\u003eModel\u003c/code\u003e class:\n\n\u003cpre lang=\"python\"\u003e\nclass User(Model, table=\"users\"):\n    name: str\n    age: int\n    items: List[str] = []\n    extra: Dict[str, Any] = {}\n\u003c/pre\u003e\n\nCreate a new instance of the model and save it to the database:\n\n\u003cpre lang=\"python\"\u003e\nuser = User.create(name=\"Alice\", age=30)\n\u003c/pre\u003e\n\nRetrieve a user from the database:\n\n\u003cpre lang=\"python\"\u003e\nuser = User.get(User.name == \"Alice\")\n# or user = User.get(name=\"Alice\")\nprint(user.name, user.age)\n\u003c/pre\u003e\n\nUpdate a user’s information and save it:\n\n\u003cpre lang=\"python\"\u003e\nuser.name = \"Kristy\"\nuser.save()\n\u003c/pre\u003e\n\nFilter users based on certain criteria:\n\n\u003cpre lang=\"python\"\u003e\nusers = User.filter(User.age \u003e= 20)\nfor user in users:\n    print(user.name)\n\u003c/pre\u003e\n\nDelete a user:\n\n\u003cpre lang=\"python\"\u003e\nuser.delete()\n\u003c/pre\u003e\n\n\u003ch1\u003eLicense\u003c/h1\u003e\nLightDB is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffl1yd%2Flightdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffl1yd%2Flightdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffl1yd%2Flightdb/lists"}