peewee Documentation Release 3.6.0using a SQL function to aggregate the results. query = (Person .select(Person, fn.COUNT(Pet.id).alias('pet_count')) .join(Pet, JOIN.LEFT_OUTER) # include people without pets. .group_by(Person) SELECT t1."id", t1."user_id", t1."content", t1."pub_date" FROM "message" AS t1 WHERE t1."user_id" IN ( SELECT t2."id" FROM "user" AS t2 INNER JOIN "relationship" AS t3 ON t2."id" = t3."to_user_id" "to_user_id" WHERE t3."from_user_id" = ? ) Other topics of interest There are a couple other neat things going on in the example app that are worth mentioning briefly. Support for paginating lists0 码力 | 377 页 | 399.12 KB | 1 年前3
peewee Documentation
Release 3.6.0JOIN and using a SQL function to aggregate the results. query = (Person .select(Person, fn.COUNT(Pet.id).alias('pet_count')) .join(Pet, JOIN.LEFT_OUTER) # include people without pets. .group_by(Person) SELECT t1."id", t1."user_id", t1."content", t1."pub_date" FROM "message" AS t1 WHERE t1."user_id" IN ( SELECT t2."id" FROM "user" AS t2 INNER JOIN "relationship" AS t3 ON t2."id" = t3."to_user_id" WHERE WHERE t3."from_user_id" = ? ) Other topics of interest There are a couple other neat things going on in the example app that are worth mentioning briefly. • Support for paginating lists of results is implemented0 码力 | 302 页 | 1.02 MB | 1 年前3
peewee Documentation Release 3.0.0using a SQL function to aggregate the results. query = (Person .select(Person, fn.COUNT(Pet.id).alias('pet_count')) .join(Pet, JOIN.LEFT_OUTER) # include people without pets. .group_by(Person) SELECT t1."id", t1."user_id", t1."content", t1."pub_date" FROM "message" AS t1 WHERE t1."user_id" IN ( SELECT t2."id" FROM "user" AS t2 INNER JOIN "relationship" AS t3 ON t2."id" = t3."to_user_id" "to_user_id" WHERE t3."from_user_id" = ? ) Other topics of interest There are a couple other neat things going on in the example app that are worth mentioning briefly. Support for paginating lists0 码力 | 319 页 | 361.50 KB | 1 年前3
peewee Documentation
Release 3.5.0using a SQL function to aggregate the results. query = (Person .select(Person, fn.COUNT(Pet.id).alias('pet_count')) .join(Pet, JOIN.LEFT_OUTER) # include people without pets. .group_by(Person) SELECT t1."id", t1."user_id", t1."content", t1."pub_date" FROM "message" AS t1 WHERE t1."user_id" IN ( SELECT t2."id" FROM "user" AS t2 INNER JOIN "relationship" AS t3 ON t2."id" = t3."to_user_id" "to_user_id" WHERE t3."from_user_id" = ? ) Other topics of interest There are a couple other neat things going on in the example app that are worth mentioning briefly. Support for paginating lists0 码力 | 347 页 | 380.80 KB | 1 年前3
peewee Documentation Release 3.4.0using a SQL function to aggregate the results. query = (Person .select(Person, fn.COUNT(Pet.id).alias('pet_count')) .join(Pet, JOIN.LEFT_OUTER) # include people without pets. .group_by(Person) SELECT t1."id", t1."user_id", t1."content", t1."pub_date" FROM "message" AS t1 WHERE t1."user_id" IN ( SELECT t2."id" FROM "user" AS t2 INNER JOIN "relationship" AS t3 ON t2."id" = t3."to_user_id" "to_user_id" WHERE t3."from_user_id" = ? ) Other topics of interest There are a couple other neat things going on in the example app that are worth mentioning briefly. Support for paginating lists0 码力 | 349 页 | 382.34 KB | 1 年前3
peewee Documentation
Release 3.5.0JOIN and using a SQL function to aggregate the results. query = (Person .select(Person, fn.COUNT(Pet.id).alias('pet_count')) .join(Pet, JOIN.LEFT_OUTER) # include people without pets. .group_by(Person) SELECT t1."id", t1."user_id", t1."content", t1."pub_date" FROM "message" AS t1 WHERE t1."user_id" IN ( SELECT t2."id" FROM "user" AS t2 INNER JOIN "relationship" AS t3 ON t2."id" = t3."to_user_id" (continues Contents: peewee Documentation, Release 3.5.0 (continued from previous page) WHERE t3."from_user_id" = ? ) Other topics of interest There are a couple other neat things going on in the example app0 码力 | 282 页 | 1.02 MB | 1 年前3
peewee Documentation
Release 3.4.0JOIN and using a SQL function to aggregate the results. query = (Person .select(Person, fn.COUNT(Pet.id).alias('pet_count')) .join(Pet, JOIN.LEFT_OUTER) # include people without pets. .group_by(Person) SELECT t1."id", t1."user_id", t1."content", t1."pub_date" FROM "message" AS t1 WHERE t1."user_id" IN ( SELECT t2."id" FROM "user" AS t2 INNER JOIN "relationship" AS t3 ON t2."id" = t3."to_user_id" WHERE WHERE t3."from_user_id" = ? ) 16 Chapter 1. Contents: peewee Documentation, Release 3.4.0 Other topics of interest There are a couple other neat things going on in the example app that are worth mentioning0 码力 | 284 页 | 1.03 MB | 1 年前3
peewee Documentation
Release 3.3.0JOIN and using a SQL function to aggregate the results. query = (Person .select(Person, fn.COUNT(Pet.id).alias('pet_count')) .join(Pet, JOIN.LEFT_OUTER) # include people without pets. .group_by(Person) SELECT t1."id", t1."user_id", t1."content", t1."pub_date" FROM "message" AS t1 WHERE t1."user_id" IN ( SELECT t2."id" FROM "user" AS t2 INNER JOIN "relationship" AS t3 ON t2."id" = t3."to_user_id" WHERE WHERE t3."from_user_id" = ? ) 16 Chapter 1. Contents: peewee Documentation, Release 3.3.0 Other topics of interest There are a couple other neat things going on in the example app that are worth mentioning0 码力 | 280 页 | 1.02 MB | 1 年前3
peewee Documentation Release 3.1.0using a SQL function to aggregate the results. query = (Person .select(Person, fn.COUNT(Pet.id).alias('pet_count')) .join(Pet, JOIN.LEFT_OUTER) # include people without pets. .group_by(Person) SELECT t1."id", t1."user_id", t1."content", t1."pub_date" FROM "message" AS t1 WHERE t1."user_id" IN ( SELECT t2."id" FROM "user" AS t2 INNER JOIN "relationship" AS t3 ON t2."id" = t3."to_user_id" "to_user_id" WHERE t3."from_user_id" = ? ) Other topics of interest There are a couple other neat things going on in the example app that are worth mentioning briefly. Support for paginating lists0 码力 | 332 页 | 370.77 KB | 1 年前3
peewee Documentation Release 1.0.0another way of expressing the same User.select({ User: ['*'], Tweet: [Count('id', 'count')] }).group_by('id').join(Tweet).order_by(('count', 'desc')) # do an atomic update TweetCount.update(count=F('count') >>> blog.id 2 Updating existing records Once a model instance has a primary key, any attempt to re-save it will result in an UPDATE rather than another INSERT: >>> blog.save() >>> blog.id 2 >>> blog blog.save() >>> blog.id 2 If you want to update multiple records, issue an UPDATE query. The following example will update all Entry objects, marking them as “published”, if their pub_date is less than today’s0 码力 | 101 页 | 163.20 KB | 1 年前3
共 16 条
- 1
- 2













