Skip to content

Commit 0de9ee6

Browse files
committed
Python: Improve documentation
1 parent 6dedb99 commit 0de9ee6

File tree

3 files changed

+34
-24
lines changed

3 files changed

+34
-24
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Changelog
2+
3+
## Unreleased
4+
5+
## 2024/05/17 0.0.1
6+
- Initial release

README.md

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# cratedb-sqlparse
22

33
`Antlr4` is a parser generator for reading, processing and executing text, there are several
4-
target languages (Java, Python, JavaScript, Dart...) available. CrateDB uses the Java target.
4+
target languages (Java, Python, JavaScript, Dart) available. CrateDB uses the Java target.
55

66
The repository holds libraries/packages created from some of those available languages, so
7-
far: `Python` and `JavaScript`.
8-
More might be added if needed in the future.
7+
far: `Python` and `JavaScript`. More might be added if needed in the future.
98

109
These libraries allow you to parse Crate's SQL dialect without sending it to a CrateDB instance.
1110

@@ -50,29 +49,23 @@ exceptions as error listener, dollar strings and any new one. See past commits t
5049
implemented in Python and Javascript, remember that CrateDB's SQLParser written in Java is the most
5150
complete and the default reference.
5251

53-
## Building locally & using a different CrateDB version.
52+
## Building locally & using a different CrateDB version
5453

5554
The generated parser is not uploaded to the repository since it's huge, to use the package locally or
5655
to build a different version use the build script.
5756

58-
#### Clone the project
59-
`git clone [email protected]:crate/cratedb-sqlparse.git`
60-
61-
#### Install the dependencies
62-
`pip install antlr4-python3-runtime requests`
63-
64-
#### Run the build script
65-
`python3 setup_grammar.py`
57+
### Acquire sources
58+
```shell
59+
git clone [email protected]:crate/cratedb-sqlparse.git
60+
cd cratedb-sqlparse
61+
```
6662

63+
### Install dependencies
64+
```
65+
pip install -r requirements.txt
66+
```
6767

68-
> At the end of the build script `setup_grammar.py` the target and the CrateDB version can be modified.
69-
>
70-
> ```python
71-
> if __name__ == '__main__':
72-
> version = '5.6.4'
73-
> target = Antlr4Target.python
74-
> download_cratedb_grammar(version)
75-
> compile_grammar(target)
76-
> patch_lexer(target)
77-
> set_version(target, version)
78-
>```
68+
### Generate grammar files
69+
```shell
70+
poe generate
71+
```

cratedb_sqlparse_py/README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# cratedb_sqlparse
1+
# CrateDB SQL Parser for Python
22

33
This package provides utilities to validate and split SQL statements specifically designed for CrateDB.
44

@@ -36,3 +36,14 @@ print(select_query.tree)
3636
sqlparse('SUUULECT * FROM sys.shards')
3737
# cratedb_sqlparse.parser.parser.ParsingException: line1:0 mismatched input 'SUUULECT' expecting {'SELECT', 'DEALLOCATE', ...}
3838
```
39+
40+
41+
## Development
42+
```shell
43+
git clone https://github.com/crate/cratedb-sqlparse
44+
cd cratedb-sqlparse/cratedb_sqlparse_py
45+
python3 -m venv .venv
46+
source .venv/bin/activate
47+
pip install --editable='.[develop,generate,release,test]'
48+
poe check
49+
```

0 commit comments

Comments
 (0)