diff --git a/README.md b/README.md index b7fc40f..8bb6ff0 100755 --- a/README.md +++ b/README.md @@ -408,6 +408,14 @@ The full documentation on ***StockScraper*** is [here](https://myql.readthedocs. #### Release Notes +##### 1.2.5 +----------- + +* camelCase dropped for underscore +* Support for substitution variable i.e @myvar +* Support of Remote Filters +* Support of Post Query Filters + ##### 1.2.4 ----------- diff --git a/docs/index.md b/docs/index.md index 1a7af9c..a5a7ca2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -225,7 +225,7 @@ Returns table description >>> ``` -####rawQuery(query) +####raw_query(query) Allows you to directly type your query diff --git a/docs/myql.md b/docs/myql.md index 3b9593d..44e0009 100644 --- a/docs/myql.md +++ b/docs/myql.md @@ -38,14 +38,29 @@ cond = ['yid', '=', 'josue_brunel'] ``` -#### *MQYL.buildResponse(response)* - #### *MQYL.use(yql_table_url, name=yql_table_name)* Change the service provider * ***url*** : url of the service provider +```python +>>> from myql import YQL +>>> yql = YQL(format='json') +>>> yql.use('http://www.josuebrunel.org/users.xml',name='users') +>>> response = self.yql.raw_query('select * from users', format='xml') +``` + +#### *MYQL.set({key:value, ..., keyN:valueN})* + +Set variable to use in your YQL statement + +```python +>>> from myql import YQL +>>> yql = YQL() +>>> yql.set({'home':'Congo'}) +>>> states = yql.select('geo.states', remote_filter=(5,)).where(['place', '=', '@home']) +``` #### *MQYL.desc(table=None)* @@ -111,12 +126,94 @@ This method is always followed by a **where**. It doesn t return a response if c >>> yql.select('mytable.friends').where(['name', '=', 'alain'], ['location', '!=', 'paris']) ``` -#### *MQYL.showTables()* +#### *MQYL.show_tables()* List all tables -#### *MQYL.getGUID(username)* +#### *MQYL.get_guid(username)* Return a user *guid* * ***username*** : yahoo id i.e 'josue_brunel' + + +### **Filters** + +mYQL implements 2 types of filters : + +* Remote filters +* Post Query Filters + +##### **Remote Filters** +***Remote filters*** are defined as **tuple**, such as ***()*** or ***(, )***. + +- *Python Code* : +```python +from myql import YQL +yql = YQL() +data = self.yql.get('geo.countries', remote_filter=(10,)) +``` + +- *YQL Statement* : +```sql +> SELECT * FROM geo.countries(10) ; +``` + +- *Python Code* : + +```python +data = self.yql.get('geo.countries', remote_filter=(10,20)) +``` + +- *YQL Statement* : +```sql +> SELECT * FROM geo.countries(10,20) ; +``` + + +##### **Post Query Filters** + +**Filters** or **Function** applied to the result of the ***Query***. + +- ***reverse*** +```python +func_filters = ['reverse'] +data = yql.select('geo.states', func_filters=func_filters).where(['place', '=', 'Congo']) +``` + +- ***tail*** +```python +func_filters = [('tail', 2)] +data = yql.select('geo.states', func_filters=func_filters).where(['place', '=', 'Congo']) +``` + +- ***truncate*** +```python +func_filters = [('truncate', 2)] +data = yql.select('geo.states', func_filters=func_filters).where(['place', '=', 'Congo']) +``` + +- ***unique*** +```python +func_filters = [ + {'unique': [ + ('field','content'), + ('hideRepeatCount','false') + ]}, + ('truncate', 5) +] +data = yql.get('yql.table.list', func_filters=func_filters) +``` + +- ***sort*** +```python +func_filters = [ + {'sort': [ + ('field','name'), + ('descending','true') + ]}, + ('tail', 10), + #('reverse') +] +data = yql.select('geo.counties', func_filters=func_filters).where(['place', '=', 'CA']) +``` diff --git a/docs/oauth.md b/docs/oauth.md index ad2a5c9..8e25358 100644 --- a/docs/oauth.md +++ b/docs/oauth.md @@ -13,7 +13,7 @@ You can read the full documentation [here](http://yahoo-oauth.readthedocs.org/en >>> from yahoo_oauth import OAuth1 >>> oauth = OAuth1(None, None, from_file='credentials.json') >>> yql = myql.MYQL(format='xml',oauth=oauth) ->>> response = yql.getGUID('josue_brunel') +>>> response = yql.get_guid('josue_brunel') ... ```