pypika.queries module

class pypika.queries.Join(item, how)[source]

Bases: object

get_sql(**kwargs)[source]
class pypika.queries.JoinOn(item, how, criteria)[source]

Bases: pypika.queries.Join

get_sql(**kwargs)[source]
validate(_from, _joins)[source]
class pypika.queries.JoinUsing(item, how, fields)[source]

Bases: pypika.queries.Join

get_sql(**kwargs)[source]
validate(_from, _joins)[source]
class pypika.queries.Joiner(query, item, how, type_label)[source]

Bases: object

on(criterion)[source]
on_field(*fields)[source]
using(*fields)[source]
class pypika.queries.Query[source]

Bases: object

Query is the primary class and entry point in pypika. It is used to build queries iteratively using the builder design pattern.

This class is immutable.

classmethod from_(table)[source]

Query builder entry point. Initializes query building and sets the table to select from. When using this function, the query becomes a SELECT query.

Parameters:table

Type: Table or str

An instance of a Table object or a string table name.

:returns QueryBuilder

classmethod into(table)[source]

Query builder entry point. Initializes query building and sets the table to insert into. When using this function, the query becomes an INSERT query.

Parameters:table

Type: Table or str

An instance of a Table object or a string table name.

:returns QueryBuilder

classmethod select(*terms)[source]

Query builder entry point. Initializes query building without a table and selects fields. Useful when testing SQL functions.

Parameters:terms

Type: list[expression]

A list of terms to select. These can be any type of int, float, str, bool, or Term. They cannot be a Field unless the function Query.from_ is called first.

:returns QueryBuilder

classmethod update(table)[source]

Query builder entry point. Initializes query building and sets the table to update. When using this function, the query becomes an UPDATE query.

Parameters:table

Type: Table or str

An instance of a Table object or a string table name.

:returns QueryBuilder

class pypika.queries.QueryBuilder(quote_char='"', dialect=None, wrap_union_queries=True)[source]

Bases: pypika.queries.Selectable, pypika.terms.Term

Query Builder is the main class in pypika which stores the state of a query and offers functions which allow the state to be branched immutably.

columns(*args, **kwargs)
delete(*args, **kwargs)
distinct(*args, **kwargs)
do_join(join)[source]
fields()[source]
from_(*args, **kwargs)
get_sql(with_alias=False, subquery=False, with_unions=False, **kwargs)[source]
groupby(*args, **kwargs)
having(*args, **kwargs)
ignore(*args, **kwargs)
insert(*args, **kwargs)
into(*args, **kwargs)
join(*args, **kwargs)
limit(*args, **kwargs)
offset(*args, **kwargs)
orderby(*args, **kwargs)
rollup(*args, **kwargs)
select(*args, **kwargs)
set(*args, **kwargs)
union(*args, **kwargs)
union_all(*args, **kwargs)
update(*args, **kwargs)
where(*args, **kwargs)
class pypika.queries.Selectable(alias)[source]

Bases: object

field(name)[source]
star
class pypika.queries.Table(name, schema=None, alias=None)[source]

Bases: pypika.queries.Selectable

get_sql(quote_char=None, **kwargs)[source]
pypika.queries.make_tables(*names, **kwargs)[source]