Skip to main content

sqlwhat

Build Status PyPI version

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

Installing

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

Reference

Raising issues with how SQL is parsed

Please raise an issue on the respsective parser repo:

Basic Use

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

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:

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

Metadata

Release files for sqlwhat 3.9.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlwhat 3.9.4
File Size Uploaded Provenance Actions
sqlwhat-3.9.4.tar.gz 22.4 kB Without provenance Details for sqlwhat-3.9.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sqlwhat 3.9.4
File Interpreter ABI Platform Actions
sqlwhat-3.9.4-py3-none-any.whl Python 3 none any Details for sqlwhat-3.9.4-py3-none-any.whl

Total release size: 45.2 kB

Release files / sqlwhat-3.9.4.tar.gz

Download URL sqlwhat-3.9.4.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
cb756931236ad5fc991fef4c74594c8a7ce34590a780505c198c96e65cb98d4d
BLAKE2b-256 checksum
How to use checksums
1b694a49e7a1f65389d723148f4c539c735cfedb41d6b29961e401e7d02a688a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.8.2 requests/2.25.1 setuptools/50.3.0 requests-toolbelt/1.0.0 tqdm/4.64.1 CPython/3.5.10

Release files / sqlwhat-3.9.4-py3-none-any.whl

Download URL sqlwhat-3.9.4-py3-none-any.whl
Size 22.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ecb8fd08cf55009344fe72c73c17f1d52b4b221b696afb9f9c84c71e6631509
BLAKE2b-256 checksum
How to use checksums
a6a6cd3f8b3b4dc77cfa68191c014a47d1205ed4a03abf920fc386d0d5b30ff6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.8.2 requests/2.25.1 setuptools/50.3.0 requests-toolbelt/1.0.0 tqdm/4.64.1 CPython/3.5.10

Security for sqlwhat 3.9.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.9.4 This release

2 release files No provenance

0.1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page