Skip to content

Commit

Permalink
fixes #20. Access to community table OK
Browse files Browse the repository at this point in the history
  • Loading branch information
josuebrunel committed Aug 24, 2014
1 parent ad03fbc commit a9f7408
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@ how to use
>>> yql = lokingyql.LokingYQL()
>>> yql.diagnostics = True # To turn diagnostics on
```

access to community tables
===========================

```python
>>> yql = lokingyql.LokingYQL()
>>> rep = yql.rawQuery('desc yahoo.finance.quotes ')
>>> rep.json()
{u'error': {u'lang': u'en-US', u'description': u'No definition found for Table yahoo.finance.quotes'}}
>>> yql.community= True # Setting up access to community
>>> rep = yql.rawQuery('desc yahoo.finance.quotes ')
>>> rep.json()
{u'query': {u'count': 1, u'lang': u'en-US', u'results': {u'table': {u'src': u'http://www.datatables.org/yahoo/finance/yahoo.finance.quotes.xml', u'hash': u'061616a1c033ae89aaf2cbe83790b979', u'name': u'yahoo.finance.quotes', u'request': {u'select': {u'key': {u'required': u'true', u'type': u'xs:string', u'name': u'symbol'}}}, u'meta': {u'sampleQuery': u'\n\t\t\tselect * from yahoo.finance.quotes where symbol in ("YHOO","AAPL","GOOG","MSFT")\n\t\t'}, u'security': u'ANY'}}, u'created': u'2014-08-24T11:26:48Z'}}
>>>
```

***OR***

```python
>>> import lokingyql
>>> yql = lokingyql.LokingYQL(community=True)
>>> # do your magic
```

Methods
-------

Expand Down Expand Up @@ -103,16 +127,16 @@ Same as ***SELECT***, but instead returns data.


* create()
----------------
----------

* insert()
----------------
----------

* update()
----------------
----------

* delete()
----------------
----------



Expand Down
10 changes: 7 additions & 3 deletions lokingyql/lokingyql.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
class LokingYQL(object):
'''Yet another Python Yahoo! Query Language Wrapper
'''
default_url = 'https://query.yahooapis.com/v1/public/yql'
default_url = 'https://query.yahooapis.com/v1/public/yql'
community_data = "env 'store://datatables.org/alltableswithkeys'; " #Access to community table

def __init__(self, table=None, url=default_url, format='json', oauth=None):
def __init__(self, table=None, url=default_url, community=False, format='json', oauth=None):
self.url = url
self.table = table
self.format = format
self._query = None # used to build query when using methods such as <select>, <insert>, ...
self.diagnostics = False # Who knows, someone would like to turn it ON lol
self.limit = None
self.oauth = oauth # for oauth authentification
self.community = community # True means access to community data

def __repr__(self):
'''Returns information on the current instance
Expand All @@ -24,6 +25,9 @@ def __repr__(self):

def payloadBuilder(self, query, format='json'):
'''Build the payload'''
if self.community :
query = self.community_data + query # access to community data tables

payload = {
'q' : query,
'callback' : '', #This is not javascript
Expand Down

0 comments on commit a9f7408

Please sign in to comment.