{"id":26243763,"url":"https://github.com/danikohub/sqlaboratory","last_synced_at":"2026-04-24T17:32:01.606Z","repository":{"id":281845886,"uuid":"946588142","full_name":"DanikoHub/sqlaboratory","owner":"DanikoHub","description":"Class to make working with SQL ORM faster and easier","archived":false,"fork":false,"pushed_at":"2025-03-16T17:12:39.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-27T02:54:46.850Z","etag":null,"topics":["python3","sql","sqlalchemy"],"latest_commit_sha":null,"homepage":"","language":"Python","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/DanikoHub.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":"2025-03-11T11:25:20.000Z","updated_at":"2025-04-13T18:59:42.000Z","dependencies_parsed_at":"2025-03-11T13:28:05.937Z","dependency_job_id":"3a13baf2-da9d-4d46-89fe-097b9c624c38","html_url":"https://github.com/DanikoHub/sqlaboratory","commit_stats":null,"previous_names":["danikohub/sqlaboratory"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DanikoHub/sqlaboratory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanikoHub%2Fsqlaboratory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanikoHub%2Fsqlaboratory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanikoHub%2Fsqlaboratory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanikoHub%2Fsqlaboratory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DanikoHub","download_url":"https://codeload.github.com/DanikoHub/sqlaboratory/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanikoHub%2Fsqlaboratory/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32234555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"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":["python3","sql","sqlalchemy"],"created_at":"2025-03-13T10:31:41.084Z","updated_at":"2026-04-24T17:32:01.584Z","avatar_url":"https://github.com/DanikoHub.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SQLaboratory\n\n## What is it?\n\n**SQLaboratory is a simple way to work with SQLAlchemy library**\n\nThe idea behind is to write code like you would write SQL\n\n## How to use it\n### Select example in SQLab:\n**main.py**\n```python\nfrom sqlaboratory import SQLab\nfrom users import Users\n\nSQLab.connect(\"sqlite:///test.db\")\n\nres = SQLab.select_from(Users, \n\t_select = Users.name, \n\t_where = Users.id \u003c 3, \n\t_orderby = Users.id, \n\t_limit = 1)\n\nprint(res)\n# [('John',)]\n```\n\n**users.py**\n```python\nfrom sqlalchemy.orm import Mapped\nfrom sqlalchemy.orm import mapped_column\nfrom sqlalchemy import String\n\nfrom sqlaboratory import SQLab, Base\n\nclass Users(Base):\n\t__tablename__ = \"users\"\n\n\tid: Mapped[int] = mapped_column(primary_key=True)\n\tname: Mapped[str] = mapped_column(String, unique=True)\n\n\tdef __repr__(self) -\u003e str:\n\t\t\treturn f\"Users(id={self.id} name={self.name})\\n\\n\"\n```\n\n### Create, Update, Delete:\n**main.py**\n```python\nfrom sqlab import SQLab\nfrom users import Users\n\nSQLab.connect(\"sqlite:///test.db\")\n\nSQLab.create(Users(name = \"Simon\"))\nSQLab.update(Users, {\"name\" : \"BetterSimon\"}, _where = Users.name == \"Simon\")\nres = SQLab.select_from(Users)\nprint(res)\n# [Users(id=1 name=John), Users(id=2 name=BetterSimon)]\n\nSQLab.delete(Users, _where = Users.name == \"BetterSimon\")\nres = SQLab.select_from(Users)\nprint(res)\n# [Users(id=1 name=John)]\n```\n\n### Complex queries:\n**main.py**\n```python\nfrom sqlab import SQLab\nfrom users import Users\n\nSQLab.connect(\"sqlite:///test.db\")\n\nSQLab.create(Users(name = \"Simon\")) # 2\nSQLab.create(Users(name = \"Anne\"))  # 3\nSQLab.create(Users(name = \"Peter\")) # 4\nSQLab.create(Users(name = \"Kate\"))  # 5\nSQLab.create(Users(name = \"Alice\")) # 6\nSQLab.create(Users(name = \"Alex\"))  # 7\nSQLab.create(Users(name = \"Ben\"))   # 8\n\nres = SQLab.select_from(\n\t_from = Users,\n\t_select = [Users.name, Users.id],\n\t_where = (Users.id \u003e 3) \u0026 ((Users.id.in_([4, 5]) | (Users.id == 7))),\n\t_orderby = [Users.name, Users.id.desc()],\n\t_limit = 3)\nprint(res)\n# [('Alex', 7), ('Kate', 5), ('Peter', 4)]\n```\n\n### Get select query:\n**main.py**\n```python\nfrom sqlab import SQLab\nfrom users import Users\n\nSQLab.connect(\"sqlite:///test.db\")\n\nres = SQLab.select_from(\n\t_from = Users,\n\tis_query=True)\n# SELECT users.id AS users_id, users.name AS users_name \n# FROM users\n```\n\n### Join tables:\n**cars.py**\n```python\nfrom sqlalchemy.orm import Mapped\nfrom sqlalchemy.orm import mapped_column\nfrom sqlalchemy import String, BigInteger\n\nfrom sqlab import SQLab, Base\n\nclass Cars(Base):\n\t__tablename__ = \"cars\"\n\n\tid: Mapped[int] = mapped_column(primary_key=True)\n\tmodel: Mapped[str] = mapped_column(String)\n\tuser_id: Mapped[int] = mapped_column(BigInteger)\n\n\tdef __repr__(self) -\u003e str:\n\t\t\treturn f\"\\n\\nCars(id={self.id} model={self.model} user_id={self.user_id})\"\n```\n**main.py**\n```python\nfrom sqlab import SQLab\nfrom users import Users, RecordUser\nfrom cars import Cars, RecordCar\n\nSQLab.connect(\"sqlite:///test.db\")\n\ncars_id = Cars.id.label(\"cars_id\")\nusers_id = Users.id.label(\"users_id\")\nres = SQLab.select_from(_from = Cars, _select = [cars_id, users_id, Cars.model, Users.name], is_query=True).join(Users, Cars.user_id == Users.id).all()\nprint(res)\n# [(1, 1, 'Kia Rio', 'John'), (2, 1, 'Citroen C5', 'John'), (3, 2, 'BMW M3', 'Simon'), (4, 3, 'Toyota Land Cruiser', 'Anne')]\n```\n\n\n## What is missing\n\n- **SQL functions**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanikohub%2Fsqlaboratory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanikohub%2Fsqlaboratory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanikohub%2Fsqlaboratory/lists"}