peewee Documentation Release 2.10.2necessary to wrap your query and apply a count to the rows of the inner query (such as when using DISTINCT or GROUP BY). Peewee will usually do this automatically, but in some cases you may need to manually retrieve scalar values by calling Query.scalar(). For instance: >>> PageView.select(fn.Count(fn.Distinct(PageView.url))).scalar() 100 You can retrieve multiple scalar values by passing as_tuple=True: isolation level) aggregate([name=None[, num_params=-1]]) Class-decorator for registering custom aggregation functions. name – string name for the aggregate, defaults to the name of the class. num_params0 码力 | 275 页 | 276.96 KB | 1 年前3
peewee Documentation
Release 2.10.2necessary to wrap your query and apply a count to the rows of the inner query (such as when using DISTINCT or GROUP BY). Peewee will usually do this automatically, but in some cases you may need to manually retrieve scalar values by calling Query.scalar(). For instance: >>> PageView.select(fn.Count(fn.Distinct(PageView.url))).scalar() 100 You can retrieve multiple scalar values by passing as_tuple=True: Release 2.10.2 aggregate([name=None[, num_params=-1]]) Class-decorator for registering custom aggregation functions. Parameters • name – string name for the aggregate, defaults to the name of the class0 码力 | 221 页 | 844.06 KB | 1 年前3
peewee Documentation Release 0.9.7complex of the 4 query classes available in peewee. It supports JOIN operations on other tables, aggregation via GROUP BY and HAVING clauses, ordering via ORDER BY, and can be iterated and sliced to return annotate(related_model, aggregation=None) Parameters: related_model – related Model on which to perform aggregation, must be linked by ForeignKeyField. aggregation – the type of aggregation to use, e.g. Max('pub_date' Annotate a query with an aggregation performed on a related model, for example, “get a list of blogs with the number of entries on each”: >>> Blog.select().annotate(Entry) if aggregation is None, it will default0 码力 | 78 页 | 143.68 KB | 1 年前3
peewee Documentation Release 1.0.0complex of the 4 query classes available in peewee. It supports JOIN operations on other tables, aggregation via GROUP BY and HAVING clauses, ordering via ORDER BY, and can be iterated and sliced to return annotate(related_model, aggregation=None) Parameters: related_model – related Model on which to perform aggregation, must be linked by ForeignKeyField. aggregation – the type of aggregation to use, e.g. Max('pub_date' Annotate a query with an aggregation performed on a related model, for example, “get a list of blogs with the number of entries on each”: >>> Blog.select().annotate(Entry) if aggregation is None, it will default0 码力 | 101 页 | 163.20 KB | 1 年前3
peewee Documentation
Release 0.9.7complex of the 4 query classes available in peewee. It supports JOIN operations on other tables, aggregation via GROUP BY and HAVING clauses, ordering via ORDER BY, and can be iterated and sliced to return annotate(related_model, aggregation=None) Parameters • related_model – related Model on which to perform aggregation, must be linked by ForeignKeyField. • aggregation – the type of aggregation to use, e.g. Max(’pub_date’ Annotate a query with an aggregation performed on a related model, for example, “get a list of blogs with the number of entries on each”: >>> Blog.select().annotate(Entry) if aggregation is None, it will default0 码力 | 53 页 | 347.03 KB | 1 年前3
peewee Documentation
Release 1.0.0complex of the 4 query classes available in peewee. It supports JOIN operations on other tables, aggregation via GROUP BY and HAVING clauses, ordering via ORDER BY, and can be iterated and sliced to return annotate(related_model, aggregation=None) Parameters • related_model – related Model on which to perform aggregation, must be linked by ForeignKeyField. • aggregation – the type of aggregation to use, e.g. Max(’pub_date’ Annotate a query with an aggregation performed on a related model, for example, “get a list of blogs with the number of entries on each”: >>> Blog.select().annotate(Entry) if aggregation is None, it will default0 码力 | 71 页 | 405.29 KB | 1 年前3
peewee Documentation
Release 2.0.2complex of the 4 query classes available in peewee. It supports JOIN operations on other tables, aggregation via GROUP BY and HAVING clauses, ordering via ORDER BY, and can be iterated and sliced to return annotate(related_model, aggregation=None) Parameters • related_model – related Model on which to perform aggregation, must be linked by ForeignKeyField. • aggregation – the type of aggregation to use, e.g. fn fn.Count(Tweet.id).alias(’count’) Return type SelectQuery Annotate a query with an aggregation performed on a related model, for example, “get a list of users with the number of tweets for each”: 1.80 码力 | 65 页 | 315.33 KB | 1 年前3
peewee Documentation Release 3.0.0Examples Model Definitions Schema Creation Basic Exercises Joins and Subqueries Modifying Data Aggregation Recursion Database Initializing a Database Using Postgresql Using SQLite Using MySQL Connecting duplicates. SELECT DISTINCT surname FROM members ORDER BY surname LIMIT 10; query = (Member .select(Member.surname) .order_by(Member.surname) .limit(10) .distinct()) Combining composed using the following operators: | - UNION + - UNION ALL & - INTERSECT - - EXCEPT Simple aggregation You’d like to get the signup date of your last member. How can you retrieve this information?0 码力 | 319 页 | 361.50 KB | 1 年前3
peewee Documentation
Release 3.5.0Examples Model Definitions Schema Creation Basic Exercises Joins and Subqueries Modifying Data Aggregation Recursion Query Builder Declaring tables Select queries Insert queries Update queries Delete retrieve scalar values by calling Query.scalar(). For instance: >>> PageView.select(fn.Count(fn.Distinct(PageView.url))).scalar() 100 You can retrieve multiple scalar values by passing as_tuple=True: bin_or(value) Binary OR. .concat(other) Concatenate two strings or objects using ||. .distinct() Mark column for DISTINCT selection. Method Meaning .collate(collation) Specify column with the given collation0 码力 | 347 页 | 380.80 KB | 1 年前3
peewee Documentation Release 3.4.0Examples Model Definitions Schema Creation Basic Exercises Joins and Subqueries Modifying Data Aggregation Recursion Database Initializing a Database Using Postgresql Using SQLite Using MySQL Connecting duplicates. SELECT DISTINCT surname FROM members ORDER BY surname LIMIT 10; query = (Member .select(Member.surname) .order_by(Member.surname) .limit(10) .distinct()) Combining composed using the following operators: | - UNION + - UNION ALL & - INTERSECT - - EXCEPT Simple aggregation You’d like to get the signup date of your last member. How can you retrieve this information?0 码力 | 349 页 | 382.34 KB | 1 年前3
共 16 条
- 1
- 2













