peewee Documentation
Release 2.0.2tweet: class User(Model): username = CharField() class Tweet(Model): user = ForeignKeyField(User, related_name=’tweets’) message = TextField() created_date = DateTimeField(default=datetime.datetime.now) code lives. 1.4 Peewee Cookbook Below are outlined some of the ways to perform typical database-related tasks with peewee. Examples will use the following models: 1.4. Peewee Cookbook 7 peewee Documentation import * class User(Model): username = CharField() class Tweet(Model): user = ForeignKeyField(User, related_name=’tweets’) message = TextField() created_date = DateTimeField(default=datetime.datetime.now)0 码力 | 65 页 | 315.33 KB | 1 年前3
peewee Documentation Release 2.10.2org/wiki/Foreign_key]. This is easy to do with peewee: class Pet(Model): owner = ForeignKeyField(Person, related_name='pets') name = CharField() animal_type = CharField() class Meta: database = is "related to" and who is # "related to" a given user class Relationship(BaseModel): from_user = ForeignKeyField(User, related_name='relationships') to_user = ForeignKeyField(User, related_name='related_to') related_name='related_to') class Meta: indexes = ( # Specify a unique multi-column index on from/to-user. (('from_user', 'to_user'), True), ) # a dead simple one-to-many relationship:0 码力 | 275 页 | 276.96 KB | 1 年前3
peewee Documentation
Release 2.10.2(wikipedia). This is easy to do with peewee: class Pet(Model): owner = ForeignKeyField(Person, related_name='pets') name = CharField() animal_type = CharField() class Meta: database = db # this model user is "related to" and who is 1.3. Example app 11 peewee Documentation, Release 2.10.2 # "related to" a given user class Relationship(BaseModel): from_user = ForeignKeyField(User, related_name='relationships') related_name='relationships') to_user = ForeignKeyField(User, related_name='related_to') class Meta: indexes = ( # Specify a unique multi-column index on from/to-user. (('from_user', 'to_user'), True), ) # a dead simple0 码力 | 221 页 | 844.06 KB | 1 年前3
peewee Documentation Release 0.9.7documentation » Peewee Cookbook Below are outlined some of the ways to perform typical database-related tasks with peewee. Examples will use the following models: import peewee class Blog(peewee.Model): useful note is that you can retrieve instances related by ForeignKeyField by iterating. To get all the related instances for an object, you can query the related name. Looking at the example models, we have Entries. Entry has a foreign key to Blog, meaning that any given blog may have 0..n entries. A blog’s related entries are exposed using a SelectQuery, and can be iterated the same as any other SelectQuery:0 码力 | 78 页 | 143.68 KB | 1 年前3
peewee Documentation
Release 0.9.7the project. 1.3 Peewee Cookbook Below are outlined some of the ways to perform typical database-related tasks with peewee. Examples will use the following models: import peewee class Blog(peewee.Model): useful note is that you can retrieve instances related by ForeignKeyField by iterating. To get all the related instances for an object, you can query the related name. Looking at the example models, we have Entries. Entry has a foreign key to Blog, meaning that any given blog may have 0..n entries. A blog’s related entries are exposed using a SelectQuery, and can be iterated the same as any other SelectQuery:0 码力 | 53 页 | 347.03 KB | 1 年前3
peewee Documentation Release 1.0.0documentation » Peewee Cookbook Below are outlined some of the ways to perform typical database-related tasks with peewee. Examples will use the following models: import peewee class Blog(peewee.Model): useful note is that you can retrieve instances related by ForeignKeyField by iterating. To get all the related instances for an object, you can query the related name. Looking at the example models, we have Entries. Entry has a foreign key to Blog, meaning that any given blog may have 0..n entries. A blog’s related entries are exposed using a SelectQuery, and can be iterated the same as any other SelectQuery:0 码力 | 101 页 | 163.20 KB | 1 年前3
peewee Documentation
Release 1.0.0the project. 1.3 Peewee Cookbook Below are outlined some of the ways to perform typical database-related tasks with peewee. Examples will use the following models: 4 Chapter 1. Contents: peewee Documentation useful note is that you can retrieve instances related by ForeignKeyField by iterating. To get all the related instances for an object, you can query the related name. Looking at the example models, we have Entries. Entry has a foreign key to Blog, meaning that any given blog may have 0..n entries. A blog’s related entries are exposed using a SelectQuery, and can be iterated the same as any other SelectQuery:0 码力 | 71 页 | 405.29 KB | 1 年前3
peewee Documentation
Release 3.5.0users. by querying and joining # on different columns we can expose who a user is "related to" and who is # "related to" a given user class Relationship(BaseModel): from_user = ForeignKeyField(User ForeignKeyField(User, backref='relationships') to_user = ForeignKeyField(User, backref='related_to') class Meta: # `indexes` is a tuple of 2-tuples, where the 2-tuples are # a tuple of column names particular user object. In peewee, accessing the value of a ForeignKeyField will return the entire related object, e.g.: tweets = (Tweet .select(Tweet, User) .join(User) .order_by(Tweet0 码力 | 347 页 | 380.80 KB | 1 年前3
peewee Documentation Release 3.4.0users. by querying and joining # on different columns we can expose who a user is "related to" and who is # "related to" a given user class Relationship(BaseModel): from_user = ForeignKeyField(User ForeignKeyField(User, backref='relationships') to_user = ForeignKeyField(User, backref='related_to') class Meta: # `indexes` is a tuple of 2-tuples, where the 2-tuples are # a tuple of column names with a foundational concept in relational database systems: joining. Joining allows you to combine related information from multiple tables to answer a question. This isn’t just beneficial for ease of querying:0 码力 | 349 页 | 382.34 KB | 1 年前3
peewee Documentation Release 3.1.0users. by querying and joining # on different columns we can expose who a user is "related to" and who is # "related to" a given user class Relationship(BaseModel): from_user = ForeignKeyField(User ForeignKeyField(User, backref='relationships') to_user = ForeignKeyField(User, backref='related_to') class Meta: # `indexes` is a tuple of 2-tuples, where the 2-tuples are # a tuple of column names with a foundational concept in relational database systems: joining. Joining allows you to combine related information from multiple tables to answer a question. This isn’t just beneficial for ease of querying:0 码力 | 332 页 | 370.77 KB | 1 年前3
共 16 条
- 1
- 2













