peewee Documentation
Release 3.4.0database. To get a single record from the database, use Select.get(): grandma = Person.select().where(Person.name == 'Grandma L.').get() We can also use the equivalent shorthand Model.get(): grandma Grandma L. True # Herb False Let’s list all the cats and their owner’s name: query = Pet.select().where(Pet.animal_type == 'cat') for pet in query: print(pet.name, pet.owner.name) # prints: # Kitty Bob selecting both Pet and Person, and adding a join. query = (Pet .select(Pet, Person) .join(Person) .where(Pet.animal_type == 'cat')) for pet in query: (continues on next page) 1.2. Quickstart 7 peewee0 码力 | 284 页 | 1.03 MB | 1 年前3
peewee Documentation Release 3.4.0database. To get a single record from the database, use Select.get(): grandma = Person.select().where(Person.name == 'Grandma L.').get() We can also use the equivalent shorthand Model.get(): grandma Grandma L. True # Herb False Let’s list all the cats and their owner’s name: query = Pet.select().where(Pet.animal_type == 'cat') for pet in query: print(pet.name, pet.owner.name) # prints: # Kitty Person, and adding a join. query = (Pet .select(Pet, Person) .join(Person) .where(Pet.animal_type == 'cat')) for pet in query: print(pet.name, pet.owner.name) # prints: # Kitty0 码力 | 349 页 | 382.34 KB | 1 年前3
peewee Documentation
Release 3.3.0database. To get a single record from the database, use Select.get(): grandma = Person.select().where(Person.name == 'Grandma L.').get() We can also use the equivalent shorthand Model.get(): grandma Grandma L. True # Herb False Let’s list all the cats and their owner’s name: query = Pet.select().where(Pet.animal_type == 'cat') for pet in query: print(pet.name, pet.owner.name) # prints: # Kitty Bob selecting both Pet and Person, and adding a join. query = (Pet .select(Pet, Person) .join(Person) .where(Pet.animal_type == 'cat')) for pet in query: (continues on next page) 1.2. Quickstart 7 peewee0 码力 | 280 页 | 1.02 MB | 1 年前3
peewee Documentation
Release 3.5.0database. To get a single record from the database, use Select.get(): grandma = Person.select().where(Person.name == 'Grandma L.').get() We can also use the equivalent shorthand Model.get(): grandma Grandma L. True # Herb False Let’s list all the cats and their owner’s name: query = Pet.select().where(Pet.animal_type == 'cat') for pet in query: print(pet.name, pet.owner.name) # prints: # Kitty Bob selecting both Pet and Person, and adding a join. query = (Pet .select(Pet, Person) .join(Person) .where(Pet.animal_type == 'cat')) for pet in query: (continues on next page) 1.2. Quickstart 7 peewee0 码力 | 282 页 | 1.02 MB | 1 年前3
peewee Documentation
Release 3.5.0database. To get a single record from the database, use Select.get(): grandma = Person.select().where(Person.name == 'Grandma L.').get() We can also use the equivalent shorthand Model.get(): grandma Grandma L. True # Herb False Let’s list all the cats and their owner’s name: query = Pet.select().where(Pet.animal_type == 'cat') for pet in query: print(pet.name, pet.owner.name) # prints: # Kitty Person, and adding a join. query = (Pet .select(Pet, Person) .join(Person) .where(Pet.animal_type == 'cat')) for pet in query: print(pet.name, pet.owner.name) # prints: # Kitty0 码力 | 347 页 | 380.80 KB | 1 年前3
peewee Documentation Release 3.1.0database. To get a single record from the database, use Select.get(): grandma = Person.select().where(Person.name == 'Grandma L.').get() We can also use the equivalent shorthand Model.get(): grandma Grandma L. True # Herb False Let’s list all the cats and their owner’s name: query = Pet.select().where(Pet.animal_type == 'cat') for pet in query: print(pet.name, pet.owner.name) # prints: # Kitty Person, and adding a join. query = (Pet .select(Pet, Person) .join(Person) .where(Pet.animal_type == 'cat')) for pet in query: print(pet.name, pet.owner.name) # prints: # Kitty0 码力 | 332 页 | 370.77 KB | 1 年前3
peewee Documentation Release 3.0.0database. To get a single record from the database, use SelectQuery.get(): grandma = Person.select().where(Person.name == 'Grandma L.').get() We can also use the equivalent shorthand Model.get(): grandma Grandma L. True # Herb False Let’s list all the cats and their owner’s name: query = Pet.select().where(Pet.animal_type == 'cat') for pet in query: print pet.name, pet.owner.name # prints: # Kitty Person, and adding a join. query = (Pet .select(Pet, Person) .join(Person) .where(Pet.animal_type == 'cat')) for pet in query: print pet.name, pet.owner.name # prints: # Kitty0 码力 | 319 页 | 361.50 KB | 1 年前3
peewee Documentation
Release 3.6.0database. To get a single record from the database, use Select.get(): grandma = Person.select().where(Person.name == 'Grandma L.').get() We can also use the equivalent shorthand Model.get(): grandma # Bob # Grandma L. # Herb Let’s list all the cats and their owner’s name: query = Pet.select().where(Pet.animal_type == 'cat') for pet in query: print(pet.name, pet.owner.name) # prints: # Kitty Bob next page) 1.2. Quickstart 7 peewee Documentation, Release 3.6.0 (continued from previous page) .where(Pet.animal_type == 'cat')) for pet in query: print(pet.name, pet.owner.name) # prints: # Kitty0 码力 | 302 页 | 1.02 MB | 1 年前3
peewee Documentation Release 3.6.0database. To get a single record from the database, use Select.get(): grandma = Person.select().where(Person.name == 'Grandma L.').get() We can also use the equivalent shorthand Model.get(): grandma # Bob # Grandma L. # Herb Let’s list all the cats and their owner’s name: query = Pet.select().where(Pet.animal_type == 'cat') for pet in query: print(pet.name, pet.owner.name) # prints: # Kitty Person, and adding a join. query = (Pet .select(Pet, Person) .join(Person) .where(Pet.animal_type == 'cat')) for pet in query: print(pet.name, pet.owner.name) # prints: # Kitty0 码力 | 377 页 | 399.12 KB | 1 年前3
peewee Documentation Release 1.0.0provides a lightweight querying interface over sql uses sql concepts when querying, like joins and where clauses support for special extensions like hstore [http://peewee.readthedocs.org/en/latest/peewee/playhouse Implementing Many to Many Non-integer Primary Keys Field class API Querying API Constructing queries Where clause Performing advanced queries Query evaluation QueryResultWrapper SelectQuery UpdateQuery DeleteQuery = User.select().where(Q(is_staff=True) | Q(is_superuser=True)) # get tweets by editors Tweet.select().where(user__in=editors) # how many active users are there? User.select().where(active=True).count()0 码力 | 101 页 | 163.20 KB | 1 年前3
共 453 条
- 1
- 2
- 3
- 4
- 5
- 6
- 46













