sqlwhat


Namesqlwhat JSON
Version 3.9.4 PyPI version JSON
download
home_pagehttps://github.com/datacamp/sqlwhat
SummarySubmission correctness tests for SQL
upload_time2023-09-19 07:40:13
maintainerJeroen Hermans
docs_urlNone
authorMichael Chow, Filip Schouwenaars
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # sqlwhat

[![Build Status](https://app.circleci.com/pipelines/github/datacamp/sqlwhat?branch=master)](https://app.circleci.com/pipelines/github/datacamp/sqlwhat)
[![PyPI version](https://badge.fury.io/py/sqlwhat.svg)](https://badge.fury.io/py/sqlwhat)

`sqlwhat` enables you to write Submission Correctness Tests (SCTs) for interactive SQL exercises on DataCamp.

- If you are new to teaching on DataCamp, check out https://authoring.datacamp.com.
- 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.
- For more information about writing SCTs for SQL exercises, consult https://sqlwhat.readthedocs.io.

## Installing

```
pip install sqlwhat     # install from pypi
make install            # install from source
```

## Reference

* API Docs: https://sqlwhat.readthedocs.io
* AST viewer: https://ast-viewer.datacamp.com
* Extensions: https://github.com/datacamp/sqlwhat-ext

## Raising issues with how SQL is parsed

Please raise an issue on the respsective parser repo:

* [antlr-tsql](https://github.com/datacamp/antlr-tsql)
* [antlr-psql](https://github.com/datacamp/antlr-plsql)

## Basic Use

```python
from sqlwhat.State import State    # State holds info needed for tests
from sqlwhat.Reporter import Reporter
from sqlwhat.checks import *       # imports all SCTs
from sqlalchemy import create_engine

code = "SELECT * FROM artists WHERE id < 100"

state = State(
    student_code = code,
    solution_code = code,
    pre_exercise_code = "",
    student_conn = create_engine('sqlite:///'),
    solution_conn = create_engine('sqlite:///'),
    student_result = {'id': [1,2,3], 'name': ['greg', 'jon', 'martha']},
    solution_result = {'id': [1,2,3], 'name': ['toby', 'keith', 'deb']},
    reporter = Reporter()
    )

# test below passes, since code is equal for student and solution
has_equal_ast(state)

# test below raises a TestFail error, since 'name' col of results
# doesn't match between student and solution results
check_result(state)
# shows error data
state.reporter.build_payload()

# can also be done using a chain
from sqlwhat.sct_syntax import Ex
Ex(state).check_result()
```

## Running unit tests

```bash
pytest -m "not backend"
```

If you also want to run the backend tests, you need to set a `GITHUB_TOKEN` environment variable with access to the (private) `sqlbackend` repository.
After this, you can:

```bash
make install
pytest
```

### Rules of testing

1. Running queries is the backend's job
2. If a test doesn't run queries, it doesn't need the backend
3. Very few tests should run queries

## Building Docs

Install sqlwhat and run ..

```
cd docs
make html
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/datacamp/sqlwhat",
    "name": "sqlwhat",
    "maintainer": "Jeroen Hermans",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "content-engineering@datacamp.com",
    "keywords": "",
    "author": "Michael Chow, Filip Schouwenaars",
    "author_email": "michael@datacamp.com",
    "download_url": "https://files.pythonhosted.org/packages/1b/69/4a49e7a1f65389d723148f4c539c735cfedb41d6b29961e401e7d02a688a/sqlwhat-3.9.4.tar.gz",
    "platform": null,
    "description": "# 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 < 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\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Submission correctness tests for SQL",
    "version": "3.9.4",
    "project_urls": {
        "Homepage": "https://github.com/datacamp/sqlwhat"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a6a6cd3f8b3b4dc77cfa68191c014a47d1205ed4a03abf920fc386d0d5b30ff6",
                "md5": "8e60bcf2268a0d6bdd1fe8436fe375ca",
                "sha256": "1ecb8fd08cf55009344fe72c73c17f1d52b4b221b696afb9f9c84c71e6631509"
            },
            "downloads": -1,
            "filename": "sqlwhat-3.9.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8e60bcf2268a0d6bdd1fe8436fe375ca",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 22702,
            "upload_time": "2023-09-19T07:40:11",
            "upload_time_iso_8601": "2023-09-19T07:40:11.539013Z",
            "url": "https://files.pythonhosted.org/packages/a6/a6/cd3f8b3b4dc77cfa68191c014a47d1205ed4a03abf920fc386d0d5b30ff6/sqlwhat-3.9.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1b694a49e7a1f65389d723148f4c539c735cfedb41d6b29961e401e7d02a688a",
                "md5": "c67805776d8d2b46ee87c18ce818c9c1",
                "sha256": "cb756931236ad5fc991fef4c74594c8a7ce34590a780505c198c96e65cb98d4d"
            },
            "downloads": -1,
            "filename": "sqlwhat-3.9.4.tar.gz",
            "has_sig": false,
            "md5_digest": "c67805776d8d2b46ee87c18ce818c9c1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 22450,
            "upload_time": "2023-09-19T07:40:13",
            "upload_time_iso_8601": "2023-09-19T07:40:13.330784Z",
            "url": "https://files.pythonhosted.org/packages/1b/69/4a49e7a1f65389d723148f4c539c735cfedb41d6b29961e401e7d02a688a/sqlwhat-3.9.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-19 07:40:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "datacamp",
    "github_project": "sqlwhat",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "circle": true,
    "requirements": [],
    "lcname": "sqlwhat"
}
        
Elapsed time: 0.13172s