{"id":17343560,"url":"https://github.com/maxmindlin/easy-sql","last_synced_at":"2025-03-27T09:42:00.359Z","repository":{"id":105957251,"uuid":"183325379","full_name":"maxmindlin/easy-sql","owner":"maxmindlin","description":"Lightweight MySQL connection wrapper and query builder for easy programmatic queries","archived":false,"fork":false,"pushed_at":"2019-04-25T03:12:22.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T14:31:02.248Z","etag":null,"topics":["python","sql"],"latest_commit_sha":null,"homepage":null,"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/maxmindlin.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":"2019-04-25T00:22:48.000Z","updated_at":"2019-04-25T03:12:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"747516a5-abfa-4b71-9224-11b901ac7e2a","html_url":"https://github.com/maxmindlin/easy-sql","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/maxmindlin%2Feasy-sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxmindlin%2Feasy-sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxmindlin%2Feasy-sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxmindlin%2Feasy-sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxmindlin","download_url":"https://codeload.github.com/maxmindlin/easy-sql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245820659,"owners_count":20677888,"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":["python","sql"],"created_at":"2024-10-15T16:09:42.708Z","updated_at":"2025-03-27T09:42:00.334Z","avatar_url":"https://github.com/maxmindlin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Sometimes you just need a lightweight DB client outside a traditional MVC.\n\nRequires a .env file in the format (`DB_TUNNEL` is optional if you pass `tunnel=False` to EasySQL):\n```\nDB_USER=\nDB_PASS=\nDB_HOST=\nDB_PORT=\nDB_NAME=\nDB_TUNNEL=\n```\nKeeping this consistent makes connecting easier.\n\nExample usage:\n\n```python\nquery = (\n    EasySQL(\".env\", tunnel=True)\n    .SELECT([\"users\",\"user_ids\"])\n    .FROM(\"user_table\", alias=\"ut\")\n    .JOIN(\"client_table\", alias=\"c\").LEFT().USING(\"ID\")\n    .WHERE(\"c.type = 1\")\n    .WHERE(\"ut.name = 'John'\")\n    .ORDERBY(\"ut.date_created\", by=\"desc\")\n    .LIMIT(250)\n)\n\ndata: pd.DataFrame = query.execute \n```\n\nYou can nest EasySQL objects together in subqueries:\n\n```python\n(\n    EasySQL(\".env\")\n    .SELECT([\"foo\",\"bar\"])\n    .FROM(\"table\")\n    .JOIN(\"table2\").LEFT().USING(\"field3\")\n    .SUBQUERY(\n        (\n            EasySQL(\".env\")\n            .SELECT([\"foo_\"])\n            .FROM(\"table3\")\n        ), \n        alias=\"sub_query\", \n        join_left=\"foo\", \n        join_right=\"foo_\"\n    )\n    .WHERE(\"foo = 1\")\n    .LIMIT(100)\n)\n```\n\nYou can also pull out a new SQL client like so:\n\n```python\nclient = EasySQL(\".env\").new()\n```\n\nThis just a wrap for the mysql-connector class, so it can be used similarly by pulling out the client:\n\n```python\n# This returns a mysql.connector object\nEasySQL(\".env\").new().client\n```\n\n`EasySQL().client` will only accept methods that are out of the box for mysql-connector. \nAlternatively, use the EasySQL methods for DataFrame responses if you want to pass\nfull query strings:\n\n```python\ndata: pd.DataFrame = EasySQL(\".env\").new().data_frame_query(query_string)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxmindlin%2Feasy-sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxmindlin%2Feasy-sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxmindlin%2Feasy-sql/lists"}