antlr-tsql


Nameantlr-tsql JSON
Version 0.12.6 PyPI version JSON
download
home_pagehttps://github.com/datacamp/antlr-tsql
SummaryA transact sql parser, written in Antlr4
upload_time2019-08-21 14:02:48
maintainerJeroen Hermans
docs_urlNone
authorMichael Chow
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            # antlr-tsql

[![Build Status](https://travis-ci.org/datacamp/antlr-tsql.svg?branch=master)](https://travis-ci.org/datacamp/antlr-tsql)
[![PyPI version](https://badge.fury.io/py/antlr-tsql.svg)](https://badge.fury.io/py/antlr-tsql)

## Development

ANTLR requires Java, so we suggest you use Docker when building grammars. The `Makefile` contains directives to clean, build, test and deploy the ANTLR grammar. It does not run Docker itself, so run `make` inside Docker.

### Build the grammar

```bash
# Build the docker container
docker build -t antlr_tsql .

# Run the container to build the python grammar
# Write parser files to local file system through volume mounting
docker run -it -v ${PWD}:/usr/src/app antlr_tsql make build
```

### Set up the Python module

Now that the Python parsing files are available, you can install them with `pip`:

```bash
pip install -r requirements.txt
pip install -e .
```

And parse SQL code in Python:

```python
from antlr_tsql import ast
ast.parse("SELECT a from b")
```

### Using the AST viewer

If you're actively developing on the ANLTR grammar or the tree shaping, it's a good idea to set up the [AST viewer](https://github.com/datacamp/ast-viewer) locally so you can immediately see the impact of your changes in a visual way.

- Clone the ast-viewer repo and build the Docker image according to the instructions.
- Spin up a docker container that volume mounts the Python package, symlink-installs the package and runs the server on port 3000:

```bash
docker run -it \
  -u root \
  -v ~/workspace/antlr-tsql:/app/app/antlr-tsql \
  -p 3000:3000 \
  ast-viewer \
  /bin/bash -c "echo 'Install development requirements in development:' \
    && pip install --no-deps -e app/antlr-tsql \
    && python3 run.py"
```

When simultaneously developing other packages, volume mount and install those too:

```bash
docker run -it \
  -u root \
  -v ~/workspace/antlr-ast:/app/app/antlr-ast \
  -v ~/workspace/antlr-plsql:/app/app/antlr-plsql \
  -v ~/workspace/antlr-tsql:/app/app/antlr-tsql \
  -p 3000:3000 \
  ast-viewer \
  /bin/bash -c "echo 'Install development requirements in development:' \
    && pip install --no-deps -e app/antlr-ast \
    && pip install --no-deps -e app/antlr-plsql \
    && pip install --no-deps -e app/antlr-tsql \
    && python3 run.py"
```

- If you update the tree shaping logic in this repo, the app will auto-update.
- If you change the grammar, you will have to first rebuild the grammar (with the `antlr_tsql` docker image) and restart the `ast-viewer` container.

### Run tests

```bash
# Similar to building the grammar, but running tests
# and not saving the generated files
docker build -t antlr_tsql .
docker run -t antlr_tsql make build test
```

Or run the test locally, first build the grammar then run:

```python
pytest
```

## Travis deployment

- Builds the Docker image.
- Runs the Docker image to build the grammar and run the unit tests.
- Deploys the resulting python files to PyPi when a new release is made, so they can be installed easily.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/datacamp/antlr-tsql",
    "name": "antlr-tsql",
    "maintainer": "Jeroen Hermans",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "content-engineering@datacamp.com",
    "keywords": "",
    "author": "Michael Chow",
    "author_email": "michael@datacamp.com",
    "download_url": "https://files.pythonhosted.org/packages/6d/ef/9c5be4cbe024ebacd45b4c6c7e6418b847ba5b081bfb627b833853a83eb4/antlr-tsql-0.12.6.tar.gz",
    "platform": "",
    "description": "# antlr-tsql\n\n[![Build Status](https://travis-ci.org/datacamp/antlr-tsql.svg?branch=master)](https://travis-ci.org/datacamp/antlr-tsql)\n[![PyPI version](https://badge.fury.io/py/antlr-tsql.svg)](https://badge.fury.io/py/antlr-tsql)\n\n## Development\n\nANTLR requires Java, so we suggest you use Docker when building grammars. The `Makefile` contains directives to clean, build, test and deploy the ANTLR grammar. It does not run Docker itself, so run `make` inside Docker.\n\n### Build the grammar\n\n```bash\n# Build the docker container\ndocker build -t antlr_tsql .\n\n# Run the container to build the python grammar\n# Write parser files to local file system through volume mounting\ndocker run -it -v ${PWD}:/usr/src/app antlr_tsql make build\n```\n\n### Set up the Python module\n\nNow that the Python parsing files are available, you can install them with `pip`:\n\n```bash\npip install -r requirements.txt\npip install -e .\n```\n\nAnd parse SQL code in Python:\n\n```python\nfrom antlr_tsql import ast\nast.parse(\"SELECT a from b\")\n```\n\n### Using the AST viewer\n\nIf you're actively developing on the ANLTR grammar or the tree shaping, it's a good idea to set up the [AST viewer](https://github.com/datacamp/ast-viewer) locally so you can immediately see the impact of your changes in a visual way.\n\n- Clone the ast-viewer repo and build the Docker image according to the instructions.\n- Spin up a docker container that volume mounts the Python package, symlink-installs the package and runs the server on port 3000:\n\n```bash\ndocker run -it \\\n  -u root \\\n  -v ~/workspace/antlr-tsql:/app/app/antlr-tsql \\\n  -p 3000:3000 \\\n  ast-viewer \\\n  /bin/bash -c \"echo 'Install development requirements in development:' \\\n    && pip install --no-deps -e app/antlr-tsql \\\n    && python3 run.py\"\n```\n\nWhen simultaneously developing other packages, volume mount and install those too:\n\n```bash\ndocker run -it \\\n  -u root \\\n  -v ~/workspace/antlr-ast:/app/app/antlr-ast \\\n  -v ~/workspace/antlr-plsql:/app/app/antlr-plsql \\\n  -v ~/workspace/antlr-tsql:/app/app/antlr-tsql \\\n  -p 3000:3000 \\\n  ast-viewer \\\n  /bin/bash -c \"echo 'Install development requirements in development:' \\\n    && pip install --no-deps -e app/antlr-ast \\\n    && pip install --no-deps -e app/antlr-plsql \\\n    && pip install --no-deps -e app/antlr-tsql \\\n    && python3 run.py\"\n```\n\n- If you update the tree shaping logic in this repo, the app will auto-update.\n- If you change the grammar, you will have to first rebuild the grammar (with the `antlr_tsql` docker image) and restart the `ast-viewer` container.\n\n### Run tests\n\n```bash\n# Similar to building the grammar, but running tests\n# and not saving the generated files\ndocker build -t antlr_tsql .\ndocker run -t antlr_tsql make build test\n```\n\nOr run the test locally, first build the grammar then run:\n\n```python\npytest\n```\n\n## Travis deployment\n\n- Builds the Docker image.\n- Runs the Docker image to build the grammar and run the unit tests.\n- Deploys the resulting python files to PyPi when a new release is made, so they can be installed easily.",
    "bugtrack_url": null,
    "license": "",
    "summary": "A transact sql parser, written in Antlr4",
    "version": "0.12.6",
    "project_urls": {
        "Homepage": "https://github.com/datacamp/antlr-tsql"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6def9c5be4cbe024ebacd45b4c6c7e6418b847ba5b081bfb627b833853a83eb4",
                "md5": "fbefdc5bdb8268c4077eab763ebe14da",
                "sha256": "8b3a41da30b7b8299e316abb08e815e6bfd89e06fa86121ce2da00318605c5f9"
            },
            "downloads": -1,
            "filename": "antlr-tsql-0.12.6.tar.gz",
            "has_sig": false,
            "md5_digest": "fbefdc5bdb8268c4077eab763ebe14da",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 264392,
            "upload_time": "2019-08-21T14:02:48",
            "upload_time_iso_8601": "2019-08-21T14:02:48.201603Z",
            "url": "https://files.pythonhosted.org/packages/6d/ef/9c5be4cbe024ebacd45b4c6c7e6418b847ba5b081bfb627b833853a83eb4/antlr-tsql-0.12.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2019-08-21 14:02:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "datacamp",
    "github_project": "antlr-tsql",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "antlr-tsql"
}
        
Elapsed time: 0.13220s