Skip to content

Commit 4184af9

Browse files
committed
Updated readme
1 parent 0e9bb92 commit 4184af9

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,70 @@ python-sqlparser
22
================
33

44
A Python Module for the "General SQL Parser" library (sqlparser.com)
5+
6+
Supported Systems
7+
-----------------
8+
This library currently supports: Windows 32bit/64bit and Linux 32bit/64bit.
9+
There are currently no binaries for Mac OSX available.
10+
11+
Also, please note that this module does not support Python 3.*
12+
13+
Installation
14+
------------
15+
Simply clone or download this git and execute
16+
17+
python setup.py build
18+
python setup.py install
19+
20+
The setup script will automatically download the right library (from sqlparser.com) for you.
21+
22+
Usage
23+
-----
24+
Simply import the module with
25+
import sqlparser
26+
The following example will parse a simple query:
27+
import sqlparser
28+
29+
query = "SELECT a, b FROM table_1 WHERE c > 20"
30+
parser = sqlparser.Parser()
31+
32+
# Check for syntax errors
33+
if parser.check_syntax(query) == 0:
34+
# Get first statement from the query
35+
stmt = parser.get_statement(0)
36+
37+
# Get root node
38+
root = stmt.get_root()
39+
40+
print root.__dict__
41+
42+
And print the node information the SELECT node:
43+
{'computeClause': None,
44+
'cteList': None,
45+
'expandOnClause': None,
46+
'fetchFirstClause': None,
47+
'forupdateClause': None,
48+
'fromTableList': <sqlparser.Node object at 0x7ff48c5eed50>,
49+
'groupByClause': None,
50+
'hierarchicalClause': None,
51+
'intoClause': None,
52+
'intoTableClause': None,
53+
'isolationClause': None,
54+
'leftNode': None,
55+
'limitClause': None,
56+
'lockingClause': None,
57+
'node_type': 5,
58+
'optimizeForClause': None,
59+
'orderbyClause': None,
60+
'qualifyClause': None,
61+
'resultColumnList': <sqlparser.Node object at 0x7ff48c5ee618>,
62+
'rightNode': None,
63+
'sampleClause': None,
64+
'selectDistinct': None,
65+
'selectToken': 'SELECT',
66+
'setOperator': 0,
67+
'topClause': None,
68+
'valueClause': None,
69+
'whereCondition': <sqlparser.Node object at 0x7ff48c5eea78>,
70+
'windowClause': None,
71+
'withClauses': None}

0 commit comments

Comments
 (0)