#!/usr/bin/env python
import urllib

sql="SELECT lat, long FROM nodes_legacy, node_tags WHERE id = node AND k = 'amenity' and v = 'atm';"
query = urllib.quote(sql)

print 'Original:', sql
print 'Encoded:',  query

url      = 'http://xapi.openstreet.nl:8000/python/%s'%(query)
response = urllib.urlopen(url)

print 'RESPONSE:', response
print 'URL     :', response.geturl()

headers = response.info()
print 'DATE    :', headers['date']
print 'HEADERS :'
print '---------'
print headers

data = response.read()
print 'LENGTH  :', len(data)
print 'DATA    :'
print '---------'

obj  = eval(data)
print obj
