https://github.com/kicksaw-consulting/python-soql-parser
A pyparsing-based library for parsing SOQL statements
https://github.com/kicksaw-consulting/python-soql-parser
pyparsing python salesforce soql
Last synced: about 1 year ago
JSON representation
A pyparsing-based library for parsing SOQL statements
- Host: GitHub
- URL: https://github.com/kicksaw-consulting/python-soql-parser
- Owner: Kicksaw-Consulting
- Created: 2021-04-18T09:42:11.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-07-26T17:03:43.000Z (almost 3 years ago)
- Last Synced: 2025-03-27T14:55:36.313Z (about 1 year ago)
- Topics: pyparsing, python, salesforce, soql
- Language: Python
- Homepage:
- Size: 50.8 KB
- Stars: 0
- Watchers: 2
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**CONTRIBUTORS WANTED!!**
# Installation
`pip install python-soql-parser`
or, with poetry
`poetry add python-soql-parser`
# Usage
```python
from python_soql_parser import parse
parse_result = parse("SELECT Id FROM Account")
```
where `parse_result` is a [ParseResults](https://pyparsing-docs.readthedocs.io/en/latest/HowToUsePyparsing.html#parseresults) object from [pyparsing](https://github.com/pyparsing/pyparsing/).
# Notable caveats
## Unsupported features
- Subqueries (e.g., `SELECT Name, (SELECT LastName FROM Contacts) FROM Account`)
- Aggregate queries
- SOQL specific WHERE-clause tokens (e.g., `LAST_N_DAYS:`)
## Partially supported
These are either partially supported or weakly supported
- Related attributes (e.g., `SELECT Id, Account.Name FROM Contact`). The object name is not yet parsed out on its own. This will simply parse out `"Account.Name"`
# Contributing
A lot of work remains to be done. Practically no SOQL-specific features are supported as of yet.
If you want to contribute, just open a PR! (and add a test for your new feature)
## Setting up locally
First install [poetry](https://python-poetry.org/). Afterwards, to install the dependencies, run
```
poetry install
```
## Running the tests
Simply execute
```
pytest
```
## House cleaning
Please sort imports with `isort` and format the code with `black` (in that order).