pypika.utils module

exception pypika.utils.CaseException[source]

Bases: Exception

exception pypika.utils.DialectNotSupported[source]

Bases: Exception

exception pypika.utils.FunctionException[source]

Bases: Exception

exception pypika.utils.GroupingException[source]

Bases: Exception

exception pypika.utils.JoinException[source]

Bases: Exception

exception pypika.utils.QueryException[source]

Bases: Exception

exception pypika.utils.RollupException[source]

Bases: Exception

exception pypika.utils.UnionException[source]

Bases: Exception

pypika.utils.builder(func)[source]

Decorator for wrapper “builder” functions. These are functions on the Query class or other classes used for building queries which mutate the query and return self. To make the build functions immutable, this decorator is used which will deepcopy the current instance. This decorator will return the return value of the inner function or the new copy of the instance. The inner function does not need to return self.

pypika.utils.format_alias_sql(sql, alias, quote_char=None, alias_quote_char=None, **kwargs)[source]
pypika.utils.format_quotes(value, quote_char)[source]
pypika.utils.ignore_copy(func)[source]

Decorator for wrapping the __getattr__ function for classes that are copied via deepcopy. This prevents infinite recursion caused by deepcopy looking for magic functions in the class. Any class implementing __getattr__ that is meant to be deepcopy’d should use this decorator.

deepcopy is used by pypika in builder functions (decorated by @builder) to make the results immutable. Any data model type class (stored in the Query instance) is copied.

pypika.utils.resolve_is_aggregate(values)[source]

Resolves the is_aggregate flag for an expression that contains multiple terms. This works like a voter system, each term votes True or False or abstains with None.

Parameters:values – A list of booleans (or None) for each term in the expression
Returns:If all values are True or None, True is returned. If all values are None, None is returned. Otherwise, False is returned.
pypika.utils.validate(*args, exc=None, type=None)[source]