antlr-plsql


Nameantlr-plsql JSON
Version 0.9.1 PyPI version JSON
download
home_pagehttps://github.com/datacamp/antlr-plsql
SummaryA procedural sql parser, written in Antlr4
upload_time2019-10-18 11:42:32
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-plsql

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

## 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_plsql .

# 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_plsql 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_plsql 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-plsql:/app/app/antlr-plsql \
  -p 3000:3000 \
  ast-viewer \
  /bin/bash -c "echo 'Install development requirements in development:' \
    && pip install --no-deps -e app/antlr-plsql \
    && 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_plsql` 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_plsql .
docker run -t antlr_plsql 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-plsql",
    "name": "antlr-plsql",
    "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/3a/54/6d96bdfbd5dee02533992fa60ec8ac53040470f2d1c4a2f751f9c8e33329/antlr-plsql-0.9.1.tar.gz",
    "platform": "",
    "description": "# antlr-plsql\n\n[![Build Status](https://travis-ci.org/datacamp/antlr-plsql.svg?branch=master)](https://travis-ci.org/datacamp/antlr-plsql)\n[![PyPI version](https://badge.fury.io/py/antlr-plsql.svg)](https://badge.fury.io/py/antlr-plsql)\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_plsql .\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_plsql 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_plsql 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-plsql:/app/app/antlr-plsql \\\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-plsql \\\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_plsql` 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_plsql .\ndocker run -t antlr_plsql 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 procedural sql parser, written in Antlr4",
    "version": "0.9.1",
    "project_urls": {
        "Homepage": "https://github.com/datacamp/antlr-plsql"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3a546d96bdfbd5dee02533992fa60ec8ac53040470f2d1c4a2f751f9c8e33329",
                "md5": "1df7725be812face1d3214645535d289",
                "sha256": "5bef8261031239176d483005fa5764eb6cafa6c7826d398f3e84d17038f88730"
            },
            "downloads": -1,
            "filename": "antlr-plsql-0.9.1.tar.gz",
            "has_sig": false,
            "md5_digest": "1df7725be812face1d3214645535d289",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 622317,
            "upload_time": "2019-10-18T11:42:32",
            "upload_time_iso_8601": "2019-10-18T11:42:32.828957Z",
            "url": "https://files.pythonhosted.org/packages/3a/54/6d96bdfbd5dee02533992fa60ec8ac53040470f2d1c4a2f751f9c8e33329/antlr-plsql-0.9.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2019-10-18 11:42:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "datacamp",
    "github_project": "antlr-plsql",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "antlr-plsql"
}
        
Elapsed time: 0.09816s