{"id":16367154,"url":"https://github.com/snower/syncany-sql","last_synced_at":"2025-10-11T15:15:55.626Z","repository":{"id":83299632,"uuid":"598451805","full_name":"snower/syncany-sql","owner":"snower","description":"Simple and easy-to-use sql execution engine","archived":false,"fork":false,"pushed_at":"2024-03-22T10:41:53.000Z","size":612,"stargazers_count":28,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T14:29:11.189Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/snower.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":"2023-02-07T06:09:59.000Z","updated_at":"2025-02-13T11:46:36.000Z","dependencies_parsed_at":"2024-01-31T08:52:17.185Z","dependency_job_id":"32fd45e0-a602-4a2b-ba57-e915ba035dea","html_url":"https://github.com/snower/syncany-sql","commit_stats":{"total_commits":128,"total_committers":1,"mean_commits":128.0,"dds":0.0,"last_synced_commit":"a270dd7757804542e0b950082bafb2a8111f6c3a"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fsyncany-sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fsyncany-sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fsyncany-sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fsyncany-sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snower","download_url":"https://codeload.github.com/snower/syncany-sql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244096709,"owners_count":20397467,"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":[],"created_at":"2024-10-11T02:48:44.959Z","updated_at":"2025-10-11T15:15:55.619Z","avatar_url":"https://github.com/snower.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Syncany-SQL\n[![Tests](https://img.shields.io/github/actions/workflow/status/snower/syncany-sql/ci.yml?label=tests)](https://github.com/snower/syncany-sql/actions/workflows/ci.yml)\n[![GitHub Repo stars](https://img.shields.io/github/stars/snower/syncany-sql?style=social)](https://github.com/snower/syncany-sql/stargazers)\n\n简单易用的SQL执行引擎。\n\n- 可在本地运行MySQL语法结构的SQL\n- 支持查询常用mysql、mongodb、postgresql、sqlserver、oracle、elasticsearch、influxdb、clickhouse、sqlite数据库及execl、csv、json和普通文本文件\n- 支持本地临时数据表逻辑做中间结果保存\n- 数据库数据加载使用简单条件过滤及IN条件查询\n- 因由本地完成Join匹配所以支持不同库表、不同主机及不同类型数据库间Join关联查询\n- Group By分组聚合计算及Order By排序也由本地执行，保证数据库安全性\n- 数据写Insert Into支持 ”仅插入 I“、”仅更新 U“、”存在更新否则插入 UI“、”存在更新否则插入其余删除 UDI“、”删除后插入 DI“四种模式\n- 大数据量支持批次执行，有Group By或Having条件过滤自动执行Reduce合并结果\n- 支持流式执行\n- 支持使用常用MySQL函数\n- 支持分区窗口函数查询\n- 支持使用pyeval执行python代码（调用的就是python的eval函数）\n\n-----\n\n- [安装](#安装)\n- [特性与限制](docs/feature-restrictions.md)\n- [配置详解](docs/configure.md)\n- [驱动依赖](docs/driver-dependency.md)\n- [示例详解](examples)\n- [内置函数](docs/functions.md)\n- [使用教程](docs/使用教程/)\n\n## 安装\n\n```bash\npip3 install syncanysql\n```\n\n#### Docker\n\n```bash\ndocker pull sujin190/syncany-sql\n```\n\n## 查询Nginx日志\n\n```sql\n-- 查询访问量最高的三个IP\nSELECT seg0 AS ip, COUNT(*) AS cnt FROM `file://data/access.log?sep= ` GROUP BY seg0 ORDER BY cnt DESC LIMIT 3;\n```\n\n## 查询JSON文件\n\n```sql\nSELECT\n    a.site_id,\n    b.name AS site_name,\n    IF(c.site_amount \u003e 0, c.site_amount, 0) AS site_amount,\n    MAX(a.timeout_at) AS timeout_at,\n    MAX(a.vip_timeout_at) AS vip_timeout_at,\n    now() as `created_at?`\nFROM\n    (SELECT\n        YIELD_ARRAY(sites) AS site_id,\n            IF(vip_type = '2', GET_VALUE(rules, 0, 'timeout_time'), '') AS timeout_at,\n            IF(vip_type = '1', GET_VALUE(rules, 0, 'timeout_time'), '') AS vip_timeout_at\n    FROM\n        `data/demo.json`\n    WHERE\n        start_date \u003e= '2021-01-01') a\n        JOIN\n    `data/sites.json` b ON a.site_id = b.site_id\n        JOIN\n    (SELECT\n        site_id, SUM(amount) AS site_amount\n    FROM\n        `data/orders.json`\n    WHERE\n        status \u003c= 0\n    GROUP BY site_id) c ON a.site_id = c.site_id\nGROUP BY a.site_id;\n```\n\n# Python API\n\n```python\nfrom syncanysql import ScriptEngine\n\nwith ScriptEngine() as engine:\n    engine.execute('''\n        INSERT INTO `top_ips` SELECT\n            ip, cnt\n        FROM\n            (SELECT\n                seg0 AS ip, COUNT(*) AS cnt\n            FROM\n                `file:///var/log/nginx/access.log?sep= `\n            GROUP BY seg0) a\n        ORDER BY cnt DESC\n        LIMIT 3;\n    ''')\n    print(engine.pop_memory_datas(\"top_ips\"))\n```\n\n# License\n\nSyncany-SQL uses the MIT license, see LICENSE file for the details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnower%2Fsyncany-sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnower%2Fsyncany-sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnower%2Fsyncany-sql/lists"}