summaryrefslogtreecommitdiff
path: root/extras/appengine/static/sqlformat_client_example.py
blob: e4d1606a67b9e032391e5260d0b466c9c005b457 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python

import urllib
import urllib2

REMOTE_API = 'http://sqlformat.appspot.com/format/'
REMOTE_API = 'http://127.0.0.1:8080/format/'

payload = (
    ('data', 'select * from foo join bar on val1 = val2 where id = 123;'),
    ('format', 'text'),
    ('keyword_case', 'upper'),
    ('reindent', True),
    ('n_indents', 2),
    )

response = urllib2.urlopen(REMOTE_API,
                           urllib.urlencode(payload))
print response.read()