peewee Documentation Release 1.0.0documentation » Overview peewee is a lightweight ORM [http://en.wikipedia.org/wiki/Object-relational_mapping] written in python. Examples: # a simple query selecting a user User.get(username='charles') # foreign-keys to the User model and represents “following”. Message: analagous to a tweet. this model stores the text content of the message, when it was created, and who posted it (foreign key to User) related_name='relationships') to_user = ForeignKeyField(User, related_name='related_to') class Message(BaseModel): user = ForeignKeyField(User) content = TextField() pub_date = DateTimeField()0 码力 | 101 页 | 163.20 KB | 1 年前3
peewee Documentation Release 3.4.0two foreign-keys to the User model and stores which users follow one another. Message: Analagous to a tweet. The Message model stores the text content of the tweet, when it was created, and who posted didn't specify, a users messages will be accessible # as a special attribute, User.messages class Message(BaseModel): user = ForeignKeyField(User, backref='messages') content = TextField() pub_date this: def create_tables(): with database: database.create_tables([User, Relationship, Message]) Open a python shell in the directory alongside the example app and execute the following: >>>0 码力 | 349 页 | 382.34 KB | 1 年前3
peewee Documentation Release 3.0.0two foreign-keys to the User model and stores which users follow one another. Message: Analagous to a tweet. The Message model stores the text content of the tweet, when it was created, and who posted didn't specify, a users messages will be accessible # as a special attribute, User.messages class Message(BaseModel): user = ForeignKeyField(User, backref='messages') content = TextField() pub_date this: def create_tables(): with database: database.create_tables([User, Relationship, Message]) Open a python shell in the directory alongside the example app and execute the following: >>>0 码力 | 319 页 | 361.50 KB | 1 年前3
peewee Documentation
Release 1.0.0foreign-keys to the User model and represents “follow- ing”. Message: analagous to a tweet. this model stores the text content of the message, when it was created, and who posted it (foreign key to User) related_name=’relationships’) to_user = ForeignKeyField(User, related_name=’related_to’) class Message(BaseModel): user = ForeignKeyField(User) content = TextField() pub_date = DateTimeField() 16 Chapter module and looks like this: def create_tables(): User.create_table() Relationship.create_table() Message.create_table() Every model has a create_table() classmethod which runs a CREATE TABLE statement0 码力 | 71 页 | 405.29 KB | 1 年前3
peewee Documentation
Release 3.4.0two foreign-keys to the User model and stores which users follow one another. Message: Analagous to a tweet. The Message model stores the text content of the tweet, when it was created, and who posted didn't specify, a users messages will be accessible # as a special attribute, User.messages class Message(BaseModel): user = ForeignKeyField(User, backref='messages') content = TextField() pub_date = DateTimeField() accomplish this: def create_tables(): with database: database.create_tables([User, Relationship, Message]) Open a python shell in the directory alongside the example app and execute the following: >>>0 码力 | 284 页 | 1.03 MB | 1 年前3
peewee Documentation
Release 3.5.0two foreign-keys to the User model and stores which users follow one another. Message: Analagous to a tweet. The Message model stores the text content of the tweet, when it was created, and who posted didn't specify, a users messages will be accessible # as a special attribute, User.messages class Message(BaseModel): user = ForeignKeyField(User, backref='messages') content = TextField() pub_date this: def create_tables(): with database: database.create_tables([User, Relationship, Message]) Open a python shell in the directory alongside the example app and execute the following: >>>0 码力 | 347 页 | 380.80 KB | 1 年前3
peewee Documentation Release 3.1.0two foreign-keys to the User model and stores which users follow one another. Message: Analagous to a tweet. The Message model stores the text content of the tweet, when it was created, and who posted didn't specify, a users messages will be accessible # as a special attribute, User.messages class Message(BaseModel): user = ForeignKeyField(User, backref='messages') content = TextField() pub_date this: def create_tables(): with database: database.create_tables([User, Relationship, Message]) Open a python shell in the directory alongside the example app and execute the following: >>>0 码力 | 332 页 | 370.77 KB | 1 年前3
peewee Documentation
Release 3.3.0two foreign-keys to the User model and stores which users follow one another. Message: Analagous to a tweet. The Message model stores the text content of the tweet, when it was created, and who posted didn't specify, a users messages will be accessible # as a special attribute, User.messages class Message(BaseModel): user = ForeignKeyField(User, backref='messages') content = TextField() pub_date = DateTimeField() accomplish this: def create_tables(): with database: database.create_tables([User, Relationship, Message]) Open a python shell in the directory alongside the example app and execute the following: >>>0 码力 | 280 页 | 1.02 MB | 1 年前3
peewee Documentation
Release 3.5.0two foreign-keys to the User model and stores which users follow one another. Message: Analagous to a tweet. The Message model stores the text content of the tweet, when it was created, and who posted didn't specify, a users messages will be accessible # as a special attribute, User.messages class Message(BaseModel): user = ForeignKeyField(User, backref='messages') content = TextField() pub_date = DateTimeField() accomplish this: def create_tables(): with database: database.create_tables([User, Relationship, Message]) Open a python shell in the directory alongside the example app and execute the following: >>>0 码力 | 282 页 | 1.02 MB | 1 年前3
peewee Documentation Release 2.10.2two foreign-keys to the User model and stores which users follow one another. Message: Analagous to a tweet. The Message model stores the text content of the tweet, when it was created, and who posted we didn't specify, a users messages will be accessible # as a special attribute, User.message_set class Message(BaseModel): user = ForeignKeyField(User) content = TextField() pub_date = DateTimeField() this: def create_tables(): database.connect() database.create_tables([User, Relationship, Message]) Open a python shell in the directory alongside the example app and execute the following: >>>0 码力 | 275 页 | 276.96 KB | 1 年前3
共 16 条
- 1
- 2













