Skip to content

Commit

Permalink
#9 WHER : it's damn working, only with AND though
Browse files Browse the repository at this point in the history
  • Loading branch information
josuebrunel committed Aug 16, 2014
1 parent a6f14dd commit b29597f
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions lokingyql/lokingyql.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import requests
import errors

import pdb

class LokingYQL(object):
'''Yet another Python Yahoo! Query Language Wrapper
Expand Down Expand Up @@ -46,6 +49,13 @@ def executeQuery(self, payload):

return response

def clauseFormatter(self, cond):
'''Formats conditions
args is a list of ['column', 'operator', 'value']
'''
cond[2] = "'{0}'".format(cond[2])
return ''.join(cond)

def buildResponse(self, response):
'''Try to return a pretty formatted response object
'''
Expand Down Expand Up @@ -92,10 +102,20 @@ def select(self, table=None, items=[]):
return self

def where(self, *args):
''' This method simulates a where condition. Use as follow:
>>>yql.select('mytable').where([('name', '=', 'alain'), ('location', '!=', 'paris')])
'''
return None
''' This method simulates a where condition. Use as follow:
>>>yql.select('mytable').where([('name', '=', 'alain'), ('location', '!=', 'paris')])
'''
if not self.table:
raise errors.NoTableSelectedError('No Table Selected')

clause = []
self._query += ' where '
for x in args:
x = self.clauseFormatter(x)
clause.append(x)

self._query += ' and '.join(clause)
return self._query

def showTables(self, format='json'):
'''Return list of all avaible tables'''
Expand Down

0 comments on commit b29597f

Please sign in to comment.