pypika.terms module¶
-
class
pypika.terms.
AggregateFunction
(name, *args, **kwargs)[source]¶ Bases:
pypika.terms.Function
-
is_aggregate
= True¶
-
-
class
pypika.terms.
AnalyticFunction
(name, *args, **kwargs)[source]¶ Bases:
pypika.terms.Function
-
is_analytic
= True¶
-
orderby
(*args, **kwargs)¶
-
over
(*args, **kwargs)¶
-
-
class
pypika.terms.
ArithmeticExpression
(operator, left, right, alias=None)[source]¶ Bases:
pypika.terms.Term
Wrapper for an arithmetic function. Can be simple with two terms or complex with nested terms. Order of operations are also preserved.
-
add_order
= [<Arithmetic.add: '+'>, <Arithmetic.sub: '-'>]¶
-
is_aggregate
¶ bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
-
mul_order
= [<Arithmetic.mul: '*'>, <Arithmetic.div: '/'>]¶
-
replace_table
(*args, **kwargs)¶
-
tables_
¶
-
-
class
pypika.terms.
Array
(*values)[source]¶ Bases:
pypika.terms.Tuple
-
class
pypika.terms.
BasicCriterion
(comparator, left, right, alias=None)[source]¶ Bases:
pypika.terms.Criterion
-
is_aggregate
¶ bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
-
replace_table
(*args, **kwargs)¶
-
tables_
¶
-
-
class
pypika.terms.
BetweenCriterion
(term, start, end, alias=None)[source]¶ Bases:
pypika.terms.Criterion
-
is_aggregate
¶ bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
-
replace_table
(*args, **kwargs)¶
-
tables_
¶
-
-
class
pypika.terms.
BitwiseAndCriterion
(term, value, alias=None)[source]¶ Bases:
pypika.terms.Criterion
-
replace_table
(*args, **kwargs)¶
-
tables_
¶
-
-
class
pypika.terms.
Bracket
(term)[source]¶ Bases:
pypika.terms.Tuple
-
class
pypika.terms.
Case
(alias=None)[source]¶ Bases:
pypika.terms.Term
-
else_
(*args, **kwargs)¶
-
is_aggregate
¶ bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
-
replace_table
(*args, **kwargs)¶
-
tables_
¶
-
when
(*args, **kwargs)¶
-
-
class
pypika.terms.
ComplexCriterion
(comparator, left, right, alias=None)[source]¶ Bases:
pypika.terms.BasicCriterion
-
class
pypika.terms.
ContainsCriterion
(term, container, alias=None)[source]¶ Bases:
pypika.terms.Criterion
-
is_aggregate
¶ bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
-
replace_table
(*args, **kwargs)¶
-
tables_
¶
-
-
class
pypika.terms.
Criterion
(alias=None)[source]¶ Bases:
pypika.terms.Term
-
class
pypika.terms.
Field
(name, alias=None, table=None)[source]¶ Bases:
pypika.terms.Criterion
,pypika.terms.JSON
-
get_sql
(with_alias=False, with_namespace=False, quote_char=None, secondary_quote_char="'", **kwargs)[source]¶
-
replace_table
(*args, **kwargs)¶
-
tables_
¶
-
-
class
pypika.terms.
Function
(name, *args, **kwargs)[source]¶ Bases:
pypika.terms.Criterion
-
is_aggregate
¶ This is a shortcut that assumes if a function has a single argument and that argument is aggregated, then this function is also aggregated. A more sophisticated approach is needed, however it is unclear how that might work. :returns:
True if the function accepts one argument and that argument is aggregate.
-
replace_table
(*args, **kwargs)¶
-
tables_
¶
-
-
class
pypika.terms.
IgnoreNullsAnalyticFunction
(name, *args, **kwargs)[source]¶ Bases:
pypika.terms.AnalyticFunction
-
ignore_nulls
(*args, **kwargs)¶
-
-
class
pypika.terms.
Index
(name, alias=None)[source]¶ Bases:
pypika.terms.Term
-
class
pypika.terms.
Interval
(years=0, months=0, days=0, hours=0, minutes=0, seconds=0, microseconds=0, quarters=0, weeks=0, dialect=None)[source]¶ Bases:
object
-
labels
= ['YEAR', 'MONTH', 'DAY', 'HOUR', 'MINUTE', 'SECOND', 'MICROSECOND']¶
-
tables_
¶
-
templates
= {<Dialects.MYSQL: 'mysql'>: 'INTERVAL {expr} {unit}', <Dialects.POSTGRESQL: 'postgressql'>: "INTERVAL '{expr} {unit}'", <Dialects.REDSHIFT: 'redshift'>: "INTERVAL '{expr} {unit}'", <Dialects.VERTICA: 'vertica'>: "INTERVAL '{expr} {unit}'", <Dialects.ORACLE: 'oracle'>: "INTERVAL '{expr}' {unit}"}¶
-
trim_pattern
= re.compile('(^0+\\.)|(\\.0+$)|(^[0\\-.: ]+[\\-: ])|([\\-:. ][0\\-.: ]+$)')¶
-
units
= ['years', 'months', 'days', 'hours', 'minutes', 'seconds', 'microseconds']¶
-
-
class
pypika.terms.
JSON
(value, alias=None)[source]¶ Bases:
pypika.terms.Term
-
table
= None¶
-
-
class
pypika.terms.
Mod
(term, modulus, alias=None)[source]¶ Bases:
pypika.terms.Function
-
class
pypika.terms.
Negative
(term)[source]¶ Bases:
pypika.terms.Term
-
is_aggregate
¶ bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
-
-
class
pypika.terms.
NestedCriterion
(comparator, nested_comparator, left, right, nested, alias=None)[source]¶ Bases:
pypika.terms.Criterion
-
is_aggregate
¶ bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
-
replace_table
(*args, **kwargs)¶
-
tables_
¶
-
-
class
pypika.terms.
Not
(term, alias=None)[source]¶ Bases:
pypika.terms.Criterion
-
replace_table
(*args, **kwargs)¶
-
tables_
¶
-
-
class
pypika.terms.
NullCriterion
(term, alias=None)[source]¶ Bases:
pypika.terms.Criterion
-
replace_table
(*args, **kwargs)¶
-
tables_
¶
-
-
class
pypika.terms.
NullValue
(alias=None)[source]¶ Bases:
pypika.terms.Term
-
class
pypika.terms.
Parameter
(placeholder)[source]¶ Bases:
pypika.terms.Term
-
is_aggregate
= None¶
-
-
class
pypika.terms.
Pow
(term, exponent, alias=None)[source]¶ Bases:
pypika.terms.Function
-
class
pypika.terms.
PseudoColumn
(name)[source]¶ Bases:
pypika.terms.Term
Represents a pseudo column (a “column” which yields a value when selected but is not actually a real table column).
-
class
pypika.terms.
Rollup
(*terms)[source]¶ Bases:
pypika.terms.Function
-
class
pypika.terms.
Star
(table=None)[source]¶ Bases:
pypika.terms.Field
-
tables_
¶
-
-
class
pypika.terms.
Term
(alias=None)[source]¶ Bases:
object
-
as_
(*args, **kwargs)¶
-
is_aggregate
= False¶
-
replace_table
(current_table, new_table)[source]¶ Replaces all occurrences of the specified table with the new table. Useful when reusing fields across queries. The base implementation returns self because not all terms have a table property.
Parameters: - current_table – The table to be replaced.
- new_table – The table to replace with.
Returns: Self.
-
tables_
¶
-
static
wrap_constant
(val, wrapper_cls=None)[source]¶ Used for wrapping raw inputs such as numbers in Criterions and Operator.
For example, the expression F(‘abc’)+1 stores the integer part in a ValueWrapper object.
Parameters: - val – Any value.
- wrapper_cls – A pypika class which wraps a constant value so it can be handled as a component of the query.
Returns: Raw string, number, or decimal values will be returned in a ValueWrapper. Fields and other parts of the querybuilder will be returned as inputted.
-
-
class
pypika.terms.
Tuple
(*values)[source]¶ Bases:
pypika.terms.Criterion
-
is_aggregate
¶ bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
-
replace_table
(*args, **kwargs)¶
-
-
class
pypika.terms.
ValueWrapper
(value, alias=None)[source]¶ Bases:
pypika.terms.Term
-
is_aggregate
= None¶
-
-
class
pypika.terms.
Values
(field)[source]¶ Bases:
pypika.terms.Term