{"id":13631869,"url":"https://github.com/spandanb/learndb-py","last_synced_at":"2025-04-17T22:32:18.670Z","repository":{"id":37684815,"uuid":"368619201","full_name":"spandanb/learndb-py","owner":"spandanb","description":"Learn database internals by implementing it from scratch.","archived":false,"fork":false,"pushed_at":"2023-08-13T20:28:59.000Z","size":1236,"stargazers_count":1260,"open_issues_count":0,"forks_count":54,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-08-01T22:50:35.494Z","etag":null,"topics":["database"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spandanb.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-05-18T17:45:55.000Z","updated_at":"2024-08-01T19:56:43.000Z","dependencies_parsed_at":"2024-01-14T06:53:38.704Z","dependency_job_id":"100f129c-4c98-4a37-9a64-b5b0c8e9834a","html_url":"https://github.com/spandanb/learndb-py","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spandanb%2Flearndb-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spandanb%2Flearndb-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spandanb%2Flearndb-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spandanb%2Flearndb-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spandanb","download_url":"https://codeload.github.com/spandanb/learndb-py/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223768665,"owners_count":17199359,"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"],"created_at":"2024-08-01T22:02:41.690Z","updated_at":"2024-11-08T23:31:45.610Z","avatar_url":"https://github.com/spandanb.png","language":"Python","readme":"# LearnDB\n\n\u003e What I Cannot Create, I Do Not Understand -Richard Feynman\n\nIn the spirit of Feynman's immortal words, the goal of this project is to better understand the internals of databases by\nimplementing a relational database management system (RDBMS) (sqlite clone) from scratch. \n\nThis project was motivated by a desire to: 1) understand databases more deeply and 2) work on a fun project. These dual\ngoals led to a:\n- relatively simple code base \n- relatively complete RDBMS implementation\n- written in pure python\n  - No build step\n- zero configuration\n  - configuration can be overriden\n\nThis makes the learndb codebase great for tinkering with. But the product has some key limitations that means it \nshouldn't be used as an actual storage solution.\n\n### Features\n\nLearndb supports the following:\n\n- it has a rich sql (learndb-sql) with support for `select, from, where, group by, having, limit, order by` \n- custom lexer and parser built using [`lark`](https://github.com/lark-parser/lark)\n- at a high-level, there is an engine that can accept some SQL statements. These statements expresses operations on a \n  database (a collection of tables which contain data)\n- allows users/agents to connect to RDBMS in multiple ways: \n  - REPL\n  - importing python module  \n  - passing a file of commands to the engine  \n- on-disk btree implementation as backing data structure\n\n### Limitations\n\n- Very simplified [^1] implementation of floating point number arithmetic, e.g. compared to\n  [IEEE754](https://en.wikipedia.org/wiki/IEEE_754)). \n- No support for common utility features, like wildcard column expansion, e.g. `select * ...`\n- More [limitations](./docs/tutorial.md)\n\n## Getting Started: Tinkering and Beyond\n\n- To get started with `learndb` first start with [`tutorial.md`](docs/tutorial.md). \n- Then to understand the system at a deeper technical level read [`reference.md`](docs/reference.md). \nThis is essentially a complete reference manual directed at a user of the system. This outlines the operations and \ncapabilities of the system. It also describes what is (un)supported and undefined behavior. \n- `Architecture.md`` - this provides a component level breakdown of the repo and the system\n\n## Hacking\n\n### Install\n- System requirements\n  - requires a linux/macos system, since it uses `fcntl` to get exclusive read access on database file\n  - python \u003e= 3.9\n- To install for development, i.e. src can be edited from without having to reinstall:\n    - `cd \u003crepo_root\u003e`\n    - create virtualenv: `python3 -m venv venv `\n    - activate venv: `source venv/bin/activate`\n    - install requirements: `python -m pip install -r requirements.txt`\n    - install `Learndb` in edit mode: `python3 -m pip install -e .`\n\n### Run REPL\n\n```\nsource venv/bin/activate\npython run_learndb.py repl\n```\n\n### Run Tests\n\n- Run all tests:\n- `python -m pytest tests/*.py`\n\n- Run btree tests:\n-`python -m pytest -s tests/btree_tests.py`  # stdout\n- `python -m pytest tests/btree_tests.py`  # suppressed out\n\n- Run end-to-end tests:\n`python -m pytest -s  tests/e2e_tests.py`\n\n- Run end-to-end tests (employees):\n`python -m pytest -s  tests/e2e_tests_employees.py`\n\n`python -m pytest -s  tests/e2e_tests_employees.py -k test_equality_select`\n\n- Run serde tests:\n`... serde_tests.py`\n\n- Run language parser tests:\n`... lang_tests.py`\n\n- Run specific test:\n`python -m pytest tests.py -k test_name`\n\n- Clear pytest cache\n`python -m pytest --cache-clear`\n\n\n## References consulted\n\n- I started this project by following cstack's awesome [tutorial](https://cstack.github.io/db_tutorial/)\n- Later I was primarily referencing: [SQLite Database System: Design and Implementation (1st ed)](https://books.google.com/books?id=9Z6IQQnX1JEC\u0026source=gbs_similarbooks)\n- Sqlite file format: [docs](https://www.sqlite.org/fileformat2.html)\n- Postgres for how certain SQL statements are implemented and how their [documentation](https://www.postgresql.org/docs/11/index.html) is organized\n\n## Project Management\n- immanent work/issues are tracked in `tasks.md`\n- long-term ideas are tracked in `docs/future-work.md`\n\n[^1]: When evaluating the difference between two floats, e.g. `3.2 \u003e 4.2`, I consider the condition True if the \ndifference between the two is some fixed delta. The accepted epsilon should scale with the magnitude of the number\n","funding_links":[],"categories":["Python","其他__大数据"],"sub_categories":["网络服务_其他"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspandanb%2Flearndb-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspandanb%2Flearndb-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspandanb%2Flearndb-py/lists"}