From a9f740858c242dd148e57b0749d05754a711bcd7 Mon Sep 17 00:00:00 2001 From: josuebrunel Date: Sun, 24 Aug 2014 13:32:16 +0200 Subject: [PATCH] fixes #20. Access to community table OK --- README.md | 32 ++++++++++++++++++++++++++++---- lokingyql/lokingyql.py | 10 +++++++--- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4d36ff1..6a718f6 100644 --- a/README.md +++ b/README.md @@ -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 ------- @@ -103,16 +127,16 @@ Same as ***SELECT***, but instead returns data. * create() ----------------- +---------- * insert() ----------------- +---------- * update() ----------------- +---------- * delete() ----------------- +---------- diff --git a/lokingyql/lokingyql.py b/lokingyql/lokingyql.py index ac4575f..903d68e 100644 --- a/lokingyql/lokingyql.py +++ b/lokingyql/lokingyql.py @@ -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