Best Python code snippet using sure_python
Clauses.py
Source:Clauses.py
1from ...Structure import Clause2from ...Builder import WhereBuilder, HavingBuilder3class Clauses :4 """Clause manipulation component.5 Used for WHERE and HAVING query.6 """7 def __init__(self) :8 Clause.clauseType = Clause.NONE9 Clause.nestedConjunctive = Clause.CONJUNCTIVE_NONE10 Clause.nestedLevel = 011 def __clauses(self, column, operator: int, value, conjunctive: int) :12 """Add Clause object to where or having property of builder object"""13 clauseType = Clause.clauseType14 if clauseType == Clause.NONE : clauseType = Clause.WHERE15 clauseObject = Clause.create(clauseType, column, operator, value, conjunctive)16 if isinstance(self.builder, WhereBuilder) or isinstance(self.builder, HavingBuilder) :17 if Clause.clauseType == Clause.HAVING :18 self.builder.addHaving(clauseObject)19 else :20 self.builder.addWhere(clauseObject)21 else :22 raise Exception('Builder object does not support WHERE or HAVING query')23 return self24 def equal(self, column, value) :25 """WHERE or HAVING clause query with "=" operator and AND conjunctive"""26 return self.__clauses(column, Clause.OPERATOR_EQUAL, value, Clause.CONJUNCTIVE_AND)27 def orEqual(self, column, value) :28 """WHERE or HAVING clause query with "=" operator and OR conjunctive"""29 return self.__clauses(column, Clause.OPERATOR_EQUAL, value, Clause.CONJUNCTIVE_OR)30 def notEqual(self, column, value) :31 """WHERE or HAVING clause query with "!=" operator and AND conjunctive"""32 return self.__clauses(column, Clause.OPERATOR_NOT_EQUAL, value, Clause.CONJUNCTIVE_AND)33 def notOrEqual(self, column, value) :34 """WHERE or HAVING clause query with "!=" operator and OR conjunctive"""35 return self.__clauses(column, Clause.OPERATOR_NOT_EQUAL, value, Clause.CONJUNCTIVE_OR)36 def greater(self, column, value) :37 """WHERE or HAVING clause query with ">" operator and AND conjunctive"""38 return self.__clauses(column, Clause.OPERATOR_GREATER, value, Clause.CONJUNCTIVE_AND)39 def orGreater(self, column, value) :40 """WHERE or HAVING clause query with ">" operator and OR conjunctive"""41 return self.__clauses(column, Clause.OPERATOR_GREATER, value, Clause.CONJUNCTIVE_OR)42 def greaterEqual(self, column, value) :43 """WHERE or HAVING clause query with ">=" operator and AND conjunctive"""44 return self.__clauses(column, Clause.OPERATOR_GREATER_EQUAL, value, Clause.CONJUNCTIVE_AND)45 def orGreaterEqual(self, column, value) :46 """WHERE or HAVING clause query with ">=" operator and OR conjunctive"""47 return self.__clauses(column, Clause.OPERATOR_GREATER_EQUAL, value, Clause.CONJUNCTIVE_OR)48 def less(self, column, value) :49 """WHERE or HAVING clause query with "<" operator and AND conjunctive"""50 return self.__clauses(column, Clause.OPERATOR_LESS, value, Clause.CONJUNCTIVE_AND)51 def orLess(self, column, value) :52 """WHERE or HAVING clause query with "<" operator and OR conjunctive"""53 return self.__clauses(column, Clause.OPERATOR_LESS, value, Clause.CONJUNCTIVE_OR)54 def lessEqual(self, column, value) :55 """WHERE or HAVING clause query with "<=" operator and AND conjunctive"""56 return self.__clauses(column, Clause.OPERATOR_LESS_EQUAL, value, Clause.CONJUNCTIVE_AND)57 def orLessEqual(self, column, value) :58 """WHERE or HAVING clause query with "<=" operator and OR conjunctive"""59 return self.__clauses(column, Clause.OPERATOR_LESS_EQUAL, value, Clause.CONJUNCTIVE_OR)60 def between(self, column, value) :61 """WHERE or HAVING clause query with BETWEEN operator and AND conjunctive"""62 return self.__clauses(column, Clause.OPERATOR_BETWEEN, value, Clause.CONJUNCTIVE_AND)63 def orBetween(self, column, value) :64 """WHERE or HAVING clause query with BETWEEN operator and OR conjunctive"""65 return self.__clauses(column, Clause.OPERATOR_BETWEEN, value, Clause.CONJUNCTIVE_OR)66 def notBetween(self, column, value) :67 """WHERE or HAVING clause query with NOT BETWEEN operator and AND conjunctive"""68 return self.__clauses(column, Clause.OPERATOR_NOT_BETWEEN, value, Clause.CONJUNCTIVE_AND)69 def notOrBetween(self, column, value) :70 """WHERE or HAVING clause query with NOT BETWEEN operator and OR conjunctive"""71 return self.__clauses(column, Clause.OPERATOR_NOT_BETWEEN, value, Clause.CONJUNCTIVE_OR)72 def In(self, column, value) :73 """WHERE or HAVING clause query with IN operator and AND conjunctive"""74 return self.__clauses(column, Clause.OPERATOR_IN, value, Clause.CONJUNCTIVE_AND)75 def orIn(self, column, value) :76 """WHERE or HAVING clause query with IN operator and OR conjunctive"""77 return self.__clauses(column, Clause.OPERATOR_IN, value, Clause.CONJUNCTIVE_OR)78 def notIn(self, column, value) :79 """WHERE or HAVING clause query with NOT IN operator and AND conjunctive"""80 return self.__clauses(column, Clause.OPERATOR_NOT_IN, value, Clause.CONJUNCTIVE_AND)81 def notOrIn(self, column, value) :82 """WHERE or HAVING clause query with NOT IN operator and OR conjunctive"""83 return self.__clauses(column, Clause.OPERATOR_NOT_IN, value, Clause.CONJUNCTIVE_OR)84 def isNull(self, column) :85 """WHERE or HAVING clause query with NULL operator and AND conjunctive"""86 return self.__clauses(column, Clause.OPERATOR_NULL, None, Clause.CONJUNCTIVE_AND)87 def orIsNull(self, column) :88 """WHERE or HAVING clause query with NULL operator and OR conjunctive"""89 return self.__clauses(column, Clause.OPERATOR_NULL, None, Clause.CONJUNCTIVE_OR)90 def notIsNull(self, column) :91 """WHERE or HAVING clause query with NOT NULL operator and AND conjunctive"""92 return self.__clauses(column, Clause.OPERATOR_NOT_NULL, None, Clause.CONJUNCTIVE_AND)93 def notOrIsNull(self, column) :94 """WHERE or HAVING clause query with NOT NULL operator and OR conjunctive"""...
Having.py
Source:Having.py
...37 if lastClause is not None :38 lastLevel = lastClause.level()39 lastClause.level(lastLevel + 1)40 return self41 def __having(self, column, operator, value, conjunctive: int) :42 """Add Clause object to having property of Builder object"""43 clauseObject = Clause.create(Clause.HAVING, column, operator, value, conjunctive)44 if isinstance(self.builder, HavingBuilder) :45 self.builder.addHaving(clauseObject)46 else :47 raise Exception('Builder object does not support HAVING query')48 return self49 def having(self, column, operator: str, value = None) :50 """HAVING query without conjunctive"""51 return self.__having(column, operator, value, Clause.CONJUNCTIVE_NONE)52 def andHaving(self, column, operator: str, value = None) :53 """HAVING query with AND conjunctive"""54 return self.__having(column, operator, value, Clause.CONJUNCTIVE_AND)55 def orHaving(self, column, operator: str, value = None) :56 """HAVING query with OR conjunctive"""57 return self.__having(column, operator, value, Clause.CONJUNCTIVE_OR)58 def notAndHaving(self, column, operator: str, value = None) :59 """HAVING query with NOT AND conjunctive"""60 return self.__having(column, operator, value, Clause.CONJUNCTIVE_NOT_AND)61 def notOrHaving(self, column, operator: str, value = None) :62 """HAVING query with NOT OR conjunctive"""63 return self.__having(column, operator, value, Clause.CONJUNCTIVE_NOT_OR)64 def havingExpression(self, expression, operator, value, params: Iterable = ()) :65 """HAVING expression query with AND conjunctive"""66 expressionObject = Expression.create(expression, '', params)67 return self.__having(expressionObject, operator, value, Clause.CONJUNCTIVE_AND)68 def orHavingExpression(self, expression, operator, value, params: Iterable = ()) :69 """HAVING expression query with OR conjunctive"""70 expressionObject = Expression.create(expression, '', params)71 return self.__having(expressionObject, operator, value, Clause.CONJUNCTIVE_OR)72 def notHavingExpression(self, expression, operator, value, params: Iterable = ()) :73 """HAVING expression query with NOT AND conjunctive"""74 expressionObject = Expression.create(expression, '', params)75 return self.__having(expressionObject, operator, value, Clause.CONJUNCTIVE_NOT_AND)76 def notOrHavingExpression(self, expression, operator, value, params: Iterable = ()) :77 """HAVING expression query with NOT OR conjunctive"""78 expressionObject = Expression.create(expression, '', params)...
HavingBuilder.py
Source:HavingBuilder.py
1from ...Structure import Clause2class HavingBuilder :3 """Builder component for HAVING clause query4 """5 def __init__(self) :6 self.__having = ()7 def getHaving(self) -> tuple :8 """Get list of having clause"""9 return self.__having10 def lastHaving(self) -> Clause :11 """Get last having clause in having list"""12 count = len(self.__having)13 if count > 0 :14 return self.__having[count-1]15 return None16 def countHaving(self) -> int :17 """Count list of having clause"""18 return len(self.__having)19 def addHaving(self, having: Clause) :20 """Add a having clause to having list"""...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!