{"id":23221038,"url":"https://github.com/spaceshaman/ormagic","last_synced_at":"2026-01-27T05:31:25.083Z","repository":{"id":249684317,"uuid":"831481456","full_name":"SpaceShaman/ORMagic","owner":"SpaceShaman","description":"Simple and lightweight ORM for Python, built on top of Pydantic.","archived":false,"fork":false,"pushed_at":"2025-01-12T09:56:07.000Z","size":1066,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-28T23:02:03.038Z","etag":null,"topics":["database","db","fastapi","orm","postgres","postgresql","pydantic","python","sql","sqlite","sqlite3"],"latest_commit_sha":null,"homepage":"https://spaceshaman.github.io/ORMagic/","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/SpaceShaman.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-20T17:17:10.000Z","updated_at":"2025-07-17T01:42:52.000Z","dependencies_parsed_at":"2024-07-29T20:24:33.764Z","dependency_job_id":"d1b1cc4b-1301-4401-886b-9f3040ae8108","html_url":"https://github.com/SpaceShaman/ORMagic","commit_stats":null,"previous_names":["spaceshaman/ormagic"],"tags_count":24,"template":false,"template_full_name":"SpaceShaman/pypi-workflow","purl":"pkg:github/SpaceShaman/ORMagic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpaceShaman%2FORMagic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpaceShaman%2FORMagic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpaceShaman%2FORMagic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpaceShaman%2FORMagic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpaceShaman","download_url":"https://codeload.github.com/SpaceShaman/ORMagic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpaceShaman%2FORMagic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28803875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T03:44:14.111Z","status":"ssl_error","status_checked_at":"2026-01-27T03:43:33.507Z","response_time":168,"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","db","fastapi","orm","postgres","postgresql","pydantic","python","sql","sqlite","sqlite3"],"created_at":"2024-12-18T22:14:57.367Z","updated_at":"2026-01-27T05:31:25.056Z","avatar_url":"https://github.com/SpaceShaman.png","language":"Python","readme":"\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/SpaceShaman/ORMagic/raw/master/docs/assets/logo-light.png\"\u003e\n  \u003cimg src=\"https://github.com/SpaceShaman/ORMagic/raw/master/docs/assets/logo-dark.png\" alt=\"ORMagic\"\u003e\n\u003c/picture\u003e\n\n\u003c!--intro-start--\u003e\n[![GitHub License](https://img.shields.io/github/license/SpaceShaman/ORMagic)](https://github.com/SpaceShaman/ORMagic?tab=MIT-1-ov-file)\n[![Tests](https://img.shields.io/github/actions/workflow/status/SpaceShaman/ORMagic/release.yml?label=tests)](https://github.com/SpaceShaman/ORMagic/blob/master/.github/workflows/tests.yml)\n[![Codecov](https://img.shields.io/codecov/c/github/SpaceShaman/ORMagic)](https://codecov.io/gh/SpaceShaman/ORMagic)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ORMagic)](https://pypi.org/project/ORMagic)\n[![PyPI - Version](https://img.shields.io/pypi/v/ORMagic)](https://pypi.org/project/ORMagic)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-black)](https://github.com/psf/black)\n[![Linting: Ruff](https://img.shields.io/badge/linting-Ruff-black?logo=ruff\u0026logoColor=black)](https://github.com/astral-sh/ruff)\n[![Pydantic](https://img.shields.io/badge/technology-Pydantic-blue?logo=pydantic\u0026logoColor=blue)](https://docs.pydantic.dev)\n[![SQLite](https://img.shields.io/badge/technology-SQLite-blue?logo=sqlite\u0026logoColor=blue)](https://www.sqlite.org)\n[![PostgreSQL](https://img.shields.io/badge/technology-PostgreSQL-blue?logo=postgresql\u0026logoColor=blue)](https://www.postgresql.org)\n[![Pytest](https://img.shields.io/badge/testing-Pytest-red?logo=pytest\u0026logoColor=red)](https://docs.pytest.org/)\n[![Material for MkDocs](https://img.shields.io/badge/docs-Material%20for%20MkDocs-yellow?logo=MaterialForMkDocs\u0026logoColor=yellow)](https://spaceshaman.github.io/ORMagic/)\n\nThe main goal of ORMagic is to provide a simple and easy-to-use ORM for [Python](https://www.python.org/), that is easy to understand and use, while still providing the necessary features to interact with a database.\nIs based on the [Pydantic](https://docs.pydantic.dev) model and extends it with the ability to interact with [SQLite](https://www.sqlite.org) and [PostgreSQL](https://www.postgresql.org) databases.\n\n## Simple example\n\n```python\nfrom ormagic import DBModel\n\nclass User(DBModel):\n    name: str\n    age: int\n\nUser.create_table()\n\nUser(name=\"John\", age=30).save()\n\nUser.get(name=\"John\")\n\u003e\u003e\u003e User(id=1, name='John', age=30)\n```\n\u003c!--intro-end--\u003e\n\nYou can find more examples and detailed documentation at [spaceshaman.github.io/ORMagic/](https://spaceshaman.github.io/ORMagic/)\n\n## Installation\n\n\u003c!--installation-start--\u003e\nYou can install ORMagic using pip:\n\n```bash\npip install ORMagic\n```\n\nBy default, ORMagic uses [SQLite](https://www.sqlite.org) as a database, so you don't need to install any additional dependencies.\nBut if you want to use another database, you need to install the appropriate database driver, for example,\nfor [PostgreSQL](https://www.postgresql.org) you need to install [psycopg2](https://github.com/psycopg/psycopg2), you can do it with the following command:\n\n```bash\npip install ORMagic[postgres]\n```\n\nAdditionally, to use a database other than [SQLite](https://www.sqlite.org), you need to set the `ORMAGIC_DATABASE_URL` environment,\nmore information about that you can find in the [documentation](https://spaceshaman.github.io/ORMagic/settings/).\n\u003c!--installation-end--\u003e\n\n## Documentation\n\nThe full documentation is available at [spaceshaman.github.io/ORMagic/](https://spaceshaman.github.io/ORMagic/)\n\n## Features and Roadmap\n\n\u003c!--roadmap-start--\u003e\n- [x] Define table schema using Pydantic models\n- [x] Basic CRUD operations\n    - [x] Save data to the database\n    - [x] Read data from the database\n    - [x] Update data in the database\n    - [x] Delete data from the database\n- [x] Relationships between tables\n    - [x] One-to-many\n        - [x] Create a tables with a foreign key\n        - [x] Save data with a foreign key\n        - [x] Read data with a foreign key\n        - [x] Update data with a foreign key\n        - [x] Delete data with a foreign key\n            - [X] Cascade\n            - [x] Set null\n            - [x] Restrict\n            - [x] Set default\n            - [x] No action\n    - [x] One-to-one\n    - [x] Many-to-many\n- [x] Unique constraints\n- [x] Remove table\n- [x] Read all data from the database\n- [x] Filter data and retrieve multiple records\n    - [x] Equal\n    - [x] Not equal\n    - [x] Greater than\n    - [x] Greater than or equal\n    - [x] Less than\n    - [x] Less than or equal\n    - [x] Like (Pattern matching with % and _)\n    - [x] Not like (Pattern matching with % and _)\n    - [x] In (List of values)\n    - [x] Not in (List of values)\n    - [x] Between (Two values)\n    - [x] Not between (Two values)\n    - [x] Q objects to combine filters (AND, OR, NOT)\n- [x] Protect against SQL injection\n- [x] Order by\n- [x] Limit and offset\n- [x] Update table schema\n    - [x] Add new column\n    - [x] Rename column\n    - [x] Drop column\n- [x] Custom primary key\n- [x] Transactions\n- [x] Integration with databases\n    - [x] SQLite\n    - [x] PostgreSQL\n    - [ ] MySQL\n- [ ] Functions\n    - [ ] Aggregate functions\n    - [ ] String functions\n    - [ ] Date and time functions\n    - [ ] Mathematical functions\n    - [ ] Control flow functions\n- [ ] Migrations\n\u003c!--roadmap-end--\u003e\n\n## Changelog\n\n\u003c!--changelog-start--\u003e\nChanges for each release are thoroughly documented in [release notes](https://github.com/SpaceShaman/ORMagic/releases)\n\u003c!--changelog-end--\u003e\n\n## Contributing\n\n\u003c!--contributing-start--\u003e\nContributions are welcome! Feel free to open an issue or submit a pull request.\nI would like to keep the library to be safe as possible, so i would appreciate if you cover any new feature with tests to maintain 100% coverage.\n\n### Install in a development environment\n\n1. First, clone the repository:\n\n    ```bash\n    git clone git@github.com:SpaceShaman/ORMagic.git\n    ```\n\n2. Install poetry if you don't have, here you can find the [instructions](https://python-poetry.org/docs/#installing-with-the-official-installer)\n\n3. Create a virtual environment and install the dependencies:\n\n    ```bash\n    cd ORMagic\n    poetry install --no-root\n    ```\n\n4. Activate the virtual environment:\n\n    ```bash\n    poetry shell\n    ```\n\n### Run tests\n\nIf you in the virtual environment, you can run the tests with the following command:\n\n```bash\npytest\n```\n\nYou can also run the tests with coverage:\n\n```bash\npytest --cov=ormagic\n```\n\n\u003c!--contributing-end--\u003e\n\n## License\n\nThis project is licensed under the terms of the [MIT license](https://github.com/SpaceShaman/ORMagic?tab=MIT-1-ov-file)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspaceshaman%2Formagic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspaceshaman%2Formagic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspaceshaman%2Formagic/lists"}