{"id":20401338,"url":"https://github.com/zebozhuang/pysql","last_synced_at":"2026-04-28T16:36:19.703Z","repository":{"id":76747759,"uuid":"102925713","full_name":"zebozhuang/pysql","owner":"zebozhuang","description":"PySQL is a MySQL client library providing easy and convenient CURD operations without writing raw SQL.","archived":false,"fork":false,"pushed_at":"2017-10-15T12:23:55.000Z","size":33,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-05T15:31:26.132Z","etag":null,"topics":["convenient","curd","mysql","pysql","python","toml"],"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/zebozhuang.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":"2017-09-09T04:05:17.000Z","updated_at":"2022-05-27T00:54:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"93fba423-4ad0-4831-882f-09774c2d7b6a","html_url":"https://github.com/zebozhuang/pysql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zebozhuang/pysql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zebozhuang%2Fpysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zebozhuang%2Fpysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zebozhuang%2Fpysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zebozhuang%2Fpysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zebozhuang","download_url":"https://codeload.github.com/zebozhuang/pysql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zebozhuang%2Fpysql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32390050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T14:34:11.604Z","status":"ssl_error","status_checked_at":"2026-04-28T14:32:37.009Z","response_time":56,"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":["convenient","curd","mysql","pysql","python","toml"],"created_at":"2024-11-15T04:49:02.998Z","updated_at":"2026-04-28T16:36:19.683Z","avatar_url":"https://github.com/zebozhuang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"PySQL\n-----\nPySQL is a MySQL client library written in Python, it can make \n**CURD** operations easy and convenient without writing raw SQL.\n\n## Tutorial\n\n### 1. Configure\n\n#### 1.1. Configure in a toml file\n```\n    host = \"127.0.0.1\"\n    port = 3306\n    user = \"root\"\n    passwd = \"123123\"\n    charset = \"utf8\"\n    db = \"bar\"\n    mincached = 3\n    maxcached = 3\n   # maxshared = 0\n```\nPlease install [Python **toml**](https://github.com/uiri/toml) to read this file.\n\n#### 1.2. Configure in a dictionary form\n\n```\n    config = {\n        \"host\": \"127.0.0.1\",\n        \"port\": 3306,\n        \"user\": \"root\",\n        \"passwd\": \"123123\",\n        \"charset\": \"utf8\",\n        \"db\": \"bar\",\n        \"mincached\": 3,\n        \"maxcached\": 3,\n        \"maxshared\": 0\n    }\n```\n\n### 2. Instance\n\n```\n    from pysql.pool import SQLPool\n\n    pool = SQLPool(**config)\n```\n\n### 3. Insert\n\n```\n    obj = {'name': 'abc', 'age': 10}\n    insert_id = pool.insert(table='t1', obj=obj)\n```\n\n```\n    objs = [\n        {'name': 'a', 'age': 1},\n        {'name': 'b', 'age': 2},\n        {'name': 'c', 'age': 3},\n    ]\n    insert_ids = pool.insertmany(table='t1', objs=objs)\n```\n\n### 4. Update\n**obj** is the updating data and **where** is query condition.\n\n```\n    Case: id = 3\n    obj = {'age': 10}\n    where = {'id': 3}  or where = {'id__eq': 3}\n    affected_rows = pool.update(table='t1', where=where, obj=obj)\n```\n\n```\n    # Case: 12 \u003c= id \u003c= 20\n    where = {'id__gte': 12, 'id__lte': 20}\n    affected_rows = pool.update(table='t1', where=where, obj=obj)\n```\n```\n    # Case: id != 4\n    where = {'id__neq': 4}\n    affected_rows = pool.update(table='t1', where=where, obj=obj)\n```\n\n### 5. Delete\n\n```\n    # Case: id in (1, 2, 3)\n    affected_rows = pool.delete(table='t1', where={'id__in': [1, 2, 3]})\n```\n\n### 6. Select\n```\n    affected_rows = pool.query(table='t1', where={'id__in': [1, 2, 3]})\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzebozhuang%2Fpysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzebozhuang%2Fpysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzebozhuang%2Fpysql/lists"}