Skip to content

Commit

Permalink
#1: updating documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
josuebrunel committed Aug 20, 2015
1 parent d46c076 commit 1898659
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 6 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ Returns table description
>>>
```

####rawQuery(query)
####raw_query(query)

Allows you to directly type your query

Expand Down
105 changes: 101 additions & 4 deletions docs/myql.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)*

Expand Down Expand Up @@ -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 ***(<count\>)*** or ***(<start\>, <count\>)***.

- *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'])
```
2 changes: 1 addition & 1 deletion docs/oauth.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')
...
```

0 comments on commit 1898659

Please sign in to comment.