{"id":20448528,"url":"https://github.com/datacamp/sqlwhat","last_synced_at":"2025-04-13T01:27:42.002Z","repository":{"id":57470644,"uuid":"77865924","full_name":"datacamp/sqlwhat","owner":"datacamp","description":null,"archived":false,"fork":false,"pushed_at":"2024-01-25T10:54:21.000Z","size":1311,"stargazers_count":4,"open_issues_count":19,"forks_count":8,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-04-07T04:35:20.217Z","etag":null,"topics":["fs","le"],"latest_commit_sha":null,"homepage":"https://sqlwhat.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datacamp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-02T22:30:45.000Z","updated_at":"2025-01-31T18:46:50.000Z","dependencies_parsed_at":"2022-09-20T12:42:46.392Z","dependency_job_id":null,"html_url":"https://github.com/datacamp/sqlwhat","commit_stats":null,"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datacamp%2Fsqlwhat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datacamp%2Fsqlwhat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datacamp%2Fsqlwhat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datacamp%2Fsqlwhat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datacamp","download_url":"https://codeload.github.com/datacamp/sqlwhat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248652982,"owners_count":21140108,"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":["fs","le"],"created_at":"2024-11-15T10:35:33.069Z","updated_at":"2025-04-13T01:27:41.982Z","avatar_url":"https://github.com/datacamp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sqlwhat\n\n[![Build Status](https://app.circleci.com/pipelines/github/datacamp/sqlwhat?branch=master)](https://app.circleci.com/pipelines/github/datacamp/sqlwhat)\n[![PyPI version](https://badge.fury.io/py/sqlwhat.svg)](https://badge.fury.io/py/sqlwhat)\n\n`sqlwhat` enables you to write Submission Correctness Tests (SCTs) for interactive SQL exercises on DataCamp.\n\n- If you are new to teaching on DataCamp, check out https://authoring.datacamp.com.\n- If you want to learn what SCTs are and how they work, visit [this article](https://authoring.datacamp.com/courses/exercises/technical-details/sct.html) specifically.\n- For more information about writing SCTs for SQL exercises, consult https://sqlwhat.readthedocs.io.\n\n## Installing\n\n```\npip install sqlwhat     # install from pypi\nmake install            # install from source\n```\n\n## Reference\n\n* API Docs: https://sqlwhat.readthedocs.io\n* AST viewer: https://ast-viewer.datacamp.com\n* Extensions: https://github.com/datacamp/sqlwhat-ext\n\n## Raising issues with how SQL is parsed\n\nPlease raise an issue on the respsective parser repo:\n\n* [antlr-tsql](https://github.com/datacamp/antlr-tsql)\n* [antlr-psql](https://github.com/datacamp/antlr-plsql)\n\n## Basic Use\n\n```python\nfrom sqlwhat.State import State    # State holds info needed for tests\nfrom sqlwhat.Reporter import Reporter\nfrom sqlwhat.checks import *       # imports all SCTs\nfrom sqlalchemy import create_engine\n\ncode = \"SELECT * FROM artists WHERE id \u003c 100\"\n\nstate = State(\n    student_code = code,\n    solution_code = code,\n    pre_exercise_code = \"\",\n    student_conn = create_engine('sqlite:///'),\n    solution_conn = create_engine('sqlite:///'),\n    student_result = {'id': [1,2,3], 'name': ['greg', 'jon', 'martha']},\n    solution_result = {'id': [1,2,3], 'name': ['toby', 'keith', 'deb']},\n    reporter = Reporter()\n    )\n\n# test below passes, since code is equal for student and solution\nhas_equal_ast(state)\n\n# test below raises a TestFail error, since 'name' col of results\n# doesn't match between student and solution results\ncheck_result(state)\n# shows error data\nstate.reporter.build_payload()\n\n# can also be done using a chain\nfrom sqlwhat.sct_syntax import Ex\nEx(state).check_result()\n```\n\n## Running unit tests\n\n```bash\npytest -m \"not backend\"\n```\n\nIf you also want to run the backend tests, you need to set a `GITHUB_TOKEN` environment variable with access to the (private) `sqlbackend` repository.\nAfter this, you can:\n\n```bash\nmake install\npytest\n```\n\n### Rules of testing\n\n1. Running queries is the backend's job\n2. If a test doesn't run queries, it doesn't need the backend\n3. Very few tests should run queries\n\n## Building Docs\n\nInstall sqlwhat and run ..\n\n```\ncd docs\nmake html\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatacamp%2Fsqlwhat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatacamp%2Fsqlwhat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatacamp%2Fsqlwhat/lists"}