diff --git a/docs/api/pypika.analytics.rst b/docs/api/pypika.analytics.rst new file mode 100644 index 00000000..36ae82ed --- /dev/null +++ b/docs/api/pypika.analytics.rst @@ -0,0 +1,7 @@ +pypika.analytics module +======================= + +.. automodule:: pypika.analytics + :members: + :undoc-members: + :show-inheritance: \ No newline at end of file diff --git a/docs/api/pypika.dialects.rst b/docs/api/pypika.dialects.rst new file mode 100644 index 00000000..0c10e70a --- /dev/null +++ b/docs/api/pypika.dialects.rst @@ -0,0 +1,7 @@ +pypika.dialects module +====================== + +.. automodule:: pypika.dialects + :members: + :undoc-members: + :show-inheritance: \ No newline at end of file diff --git a/docs/api/pypika.pseudocolumns.rst b/docs/api/pypika.pseudocolumns.rst new file mode 100644 index 00000000..dc578333 --- /dev/null +++ b/docs/api/pypika.pseudocolumns.rst @@ -0,0 +1,7 @@ +pypika.pseudocolumns module +=========================== + +.. automodule:: pypika.pseudocolumns + :members: + :undoc-members: + :show-inheritance: \ No newline at end of file diff --git a/docs/api/pypika.rst b/docs/api/pypika.rst index bff77c90..26282846 100644 --- a/docs/api/pypika.rst +++ b/docs/api/pypika.rst @@ -3,9 +3,11 @@ pypika package .. toctree:: - + pypika.analytics + pypika.dialects pypika.enums pypika.functions + pypika.pseudocolumns pypika.queries pypika.terms pypika.utils diff --git a/docs/conf.py b/docs/conf.py index 9f49b4fa..57f8d39d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -39,6 +39,7 @@ 'sphinx.ext.coverage', 'sphinx.ext.imgmath', 'sphinx.ext.viewcode', + 'numpydoc', ] # Add any paths that contain templates here, relative to this directory. diff --git a/pypika/__init__.py b/pypika/__init__.py index 538bdfbd..a875ae00 100644 --- a/pypika/__init__.py +++ b/pypika/__init__.py @@ -1,35 +1,49 @@ """ PyPika is divided into a couple of modules, primarily the ``queries`` and ``terms`` modules. -pypika.queries --------------- +pypika.analytics +---------------- -This is where the ``Query`` class can be found which is the core class in PyPika. Also, other top level classes such -as ``Table`` can be found here. ``Query`` is a container that holds all of the ``Term`` types together and also -serializes the builder to a string. +Wrappers for SQL analytic functions -pypika.terms +pypika.dialects +--------------- + +This contains all of the dialect specific implementations of the ``Query`` class. + +pypika.enums ------------ -This module contains the classes which represent individual parts of queries that extend the ``Term`` base class. +Enumerated values are kept in this package which are used as options for Queries and Terms. pypika.functions ---------------- Wrappers for common SQL functions are stored in this package. -pypika.enums ------------- +pypika.pseudocolumns +-------------------- -Enumerated values are kept in this package which are used as options for Queries and Terms. +Wrappers for common SQL pseudocolumns are stored in this package. + +pypika.queries +-------------- + +This is where the ``Query`` class can be found which is the core class in PyPika. Also, other top level classes such +as ``Table`` can be found here. ``Query`` is a container that holds all of the ``Term`` types together and also +serializes the builder to a string. +pypika.terms +------------ + +This module contains the classes which represent individual parts of queries that extend the ``Term`` base class. pypika.utils ------------ This contains all of the utility classes such as exceptions and decorators. - """ + # noinspection PyUnresolvedReferences from pypika.dialects import ( ClickHouseQuery, diff --git a/pypika/queries.py b/pypika/queries.py index 76eeea25..223c3c95 100644 --- a/pypika/queries.py +++ b/pypika/queries.py @@ -350,6 +350,15 @@ class Query: pattern. This class is immutable. + + Examples + -------- + Simple query + + .. code-block:: python + + from pypika import Query, Field + q = Query.from_('customers').select('*').where(Field("id") == 1) """ @classmethod @@ -367,7 +376,7 @@ def from_(cls, table: Union[Selectable, str], **kwargs: Any) -> "QueryBuilder": An instance of a Table object or a string table name. - :returns QueryBuilder + :return: QueryBuilder """ return cls._builder(**kwargs).from_(table) @@ -458,7 +467,7 @@ def into(cls, table: Union[Table, str], **kwargs: Any) -> "QueryBuilder": An instance of a Table object or a string table name. - :returns QueryBuilder + :return QueryBuilder """ return cls._builder(**kwargs).into(table) @@ -478,7 +487,7 @@ def select(cls, *terms: Union[int, float, str, bool, Term], **kwargs: Any) -> "Q 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 + :return: QueryBuilder """ return cls._builder(**kwargs).select(*terms) @@ -493,7 +502,7 @@ def update(cls, table: Union[str, Table], **kwargs) -> "QueryBuilder": An instance of a Table object or a string table name. - :returns QueryBuilder + :return: QueryBuilder """ return cls._builder(**kwargs).update(table) @@ -507,7 +516,7 @@ def Table(cls, table_name: str, **kwargs) -> _TableClass: A string table name. - :returns Table + :return: Table """ kwargs["query_cls"] = cls return Table(table_name, **kwargs) @@ -523,7 +532,7 @@ def Tables(cls, *names: Union[TypedTuple[str, str], str], **kwargs: Any) -> List A list of string table names, or name and alias tuples. - :returns Table + :return: Table """ kwargs["query_cls"] = cls return make_tables(*names, **kwargs)