{"id":32605276,"url":"https://github.com/d3f0/sql-complexity","last_synced_at":"2025-10-30T10:48:24.656Z","repository":{"id":321041524,"uuid":"1084205969","full_name":"D3f0/sql-complexity","owner":"D3f0","description":null,"archived":false,"fork":false,"pushed_at":"2025-10-27T12:22:34.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-27T14:11:50.941Z","etag":null,"topics":[],"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/D3f0.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-27T11:19:31.000Z","updated_at":"2025-10-27T12:22:38.000Z","dependencies_parsed_at":"2025-10-27T14:11:56.720Z","dependency_job_id":"3cd81ff8-9771-4b64-91bc-4417be3a8c25","html_url":"https://github.com/D3f0/sql-complexity","commit_stats":null,"previous_names":["d3f0/sql-complexity"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/D3f0/sql-complexity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/D3f0%2Fsql-complexity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/D3f0%2Fsql-complexity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/D3f0%2Fsql-complexity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/D3f0%2Fsql-complexity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/D3f0","download_url":"https://codeload.github.com/D3f0/sql-complexity/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/D3f0%2Fsql-complexity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281793999,"owners_count":26562617,"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","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-10-30T10:48:21.375Z","updated_at":"2025-10-30T10:48:24.639Z","avatar_url":"https://github.com/D3f0.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SQL Complexity Estimator\n\nThis package provides a simple algorithm to calculate complexity of SQL expressions.\n\nIt's based on SQLGlot abstract syntax tree, so the provided SQL must be compatible \nwith SQLGlot engines.\n\n\nThe rules are the following:\n\n- +1 per join expression\n- +1 per predicate after WHERE or HAVING\n- +1 per CTE\n- +1 per GROUP BY expression\n- +1 per UNION or INTERSECT\n- +1 per function call\n- +1 per CASE expression\n\nThis package is inspired on the comments of this [stack overflow](https://stackoverflow.com/questions/3353634/measuring-the-complexity-of-sql-statements) thread.\n\n\n## Install\n\n```bash\npython -m pip install sql-complexity\n```\n\n```bash\npoetry add sql-complexity\n```\n\n```bash\nuv add sql-complexity\n```\n\n### Run with uvx\n\n```bash\nuvx --refresh sql-complexity\n```\n\n## Run from the CLI\n\n```bash\nsql-complexity some.sql\n```\n\n```bash\ncat myfile.sql | sql-complexity\n```\n\n## Using it in your code\n\n```python\nfrom sql_complexity import SQLComplexityAssessment\n\nassessor = SQLComplexityAssessment()\nscore = assessor.assess(contents)\nprint(score)\nprint(score.total)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd3f0%2Fsql-complexity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd3f0%2Fsql-complexity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd3f0%2Fsql-complexity/lists"}