peewee Documentation Release 2.10.2Contents: Installing and Testing Installing with git Running tests Optional dependencies Quickstart Model Definition Storing data Retrieving Data Working with existing databases What next? Example app Running Generating skeleton code Adding a new Database Driver Models and Fields Fields Creating model tables Model options and table metadata Indexes and Constraints Non-integer Primary Keys, Composite Keys Integration Fields Generic foreign keys Hybrid Attributes Key/Value Store Shortcuts Signal support pwiz, a model generator Schema Migrations Reflection Database URL CSV Utils Connection pool Read Slaves Test Utils0 码力 | 275 页 | 276.96 KB | 1 年前3
peewee Documentation
Release 2.10.2document presents a brief, high-level overview of Peewee’s primary features. This guide will cover: • Model Definition 4 Chapter 1. Contents: peewee Documentation, Release 2.10.2 • Storing data • Retrieving 1.2.1 Model Definition Model classes, fields and model instances all map to database concepts: Thing Corresponds to. . . Model class Database table Field instance Column on a table Model instance typically best to begin with your data model, by defining one or more Model classes: from peewee import * db = SqliteDatabase('people.db') class Person(Model): name = CharField() birthday = DateField()0 码力 | 221 页 | 844.06 KB | 1 年前3
peewee Documentation
Release 2.0.2we’re using the models from the cookbook, good ol’ user and tweet: class User(Model): username = CharField() class Tweet(Model): user = ForeignKeyField(User, related_name=’tweets’) message = TextField() alias(’last_date’) ).join(Tweet, JOIN_LEFT_OUTER).group_by(User) Let’s do an atomic update on a counter model (you’ll have to use your imagination): # 1.0 Counter.update(count=F(’count’) + 1).where(url=request non-auto-incrementing primary key changed: # 1.0 class OldSchool(Model): uuid = PrimaryKeyField(column_class=VarCharColumn) # 2.0 class NewSchool(Model): uuid = CharField(primary_key=True) The kwargs for the0 码力 | 65 页 | 315.33 KB | 1 年前3
peewee Documentation Release 1.0.0migrations Example app Running the example Diving into the code Model API (smells like django) Creating tables Model instances Model options Model methods Fields Field types table Self-referential Foreign collection of addons apsw, an advanced sqlite driver Postgresql Extensions (hstore, ltree) pwiz, a model generator Signal support Sqlite Extensions Swee’pea, syntactic sugar for peewee Indices and tables following models: import peewee class Blog(peewee.Model): creator = peewee.CharField() name = peewee.CharField() class Entry(peewee.Model): blog = peewee.ForeignKeyField(Blog) title =0 码力 | 101 页 | 163.20 KB | 1 年前3
peewee Documentation
Release 1.0.0Documentation, Release 1.0.0 import peewee class Blog(peewee.Model): creator = peewee.CharField() name = peewee.CharField() class Entry(peewee.Model): blog = peewee.ForeignKeyField(Blog) title = peewee.CharField() connect() To use this database with your models, specify it in an inner “Meta” class: class MyModel(Model): some_field = CharField() class Meta: database = database It is possible to use multiple databases CustomModel(peewee.Model): ... whatev = peewee.CharField() ... ... class Meta: ... database = custom_db ... >>> custom_db.connect() >>> CustomModel.create_table() Best practice: define a base model class that0 码力 | 71 页 | 405.29 KB | 1 年前3
peewee Documentation Release 0.9.7databases Example app Running the example Diving into the code Model API (smells like django) Creating tables Model instances Model options Model methods Fields Field types table Self-referential Foreign following models: import peewee class Blog(peewee.Model): creator = peewee.CharField() name = peewee.CharField() class Entry(peewee.Model): blog = peewee.ForeignKeyField(Blog) title = models from each): >>> custom_db = peewee.SqliteDatabase('custom.db') >>> class CustomModel(peewee.Model): ... whatev = peewee.CharField() ... ... class Meta: ... database = custom_db .0 码力 | 78 页 | 143.68 KB | 1 年前3
peewee Documentation
Release 0.9.7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 1.5 Model API (smells like django) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . the following models: import peewee class Blog(peewee.Model): creator = peewee.CharField() name = peewee.CharField() class Entry(peewee.Model): blog = peewee.ForeignKeyField(Blog) title = peewee.CharField() CustomModel(peewee.Model): ... whatev = peewee.CharField() ... ... class Meta: ... database = custom_db ... >>> custom_db.connect() >>> CustomModel.create_table() Best practice: define a base model class that0 码力 | 53 页 | 347.03 KB | 1 年前3
peewee Documentation Release 3.0.0Contents: Installing and Testing Installing with git Running tests Optional dependencies Quickstart Model Definition Storing data Retrieving Data Closing the database Working with existing databases What example Diving into the code More examples Contributing Patches Bugs Questions Query Examples Model Definitions Schema Creation Basic Exercises Joins and Subqueries Modifying Data Aggregation Recursion Database Errors Logging queries Adding a new Database Driver Models and Fields Fields Creating model tables Model options and table metadata Indexes and Constraints Non-integer Primary Keys, Composite Keys0 码力 | 319 页 | 361.50 KB | 1 年前3
peewee Documentation
Release 3.5.0Installing with git Running tests Optional dependencies Skip Compilation of SQLite Extensions Quickstart Model Definition Storing data Retrieving Data Closing the database Working with existing databases What Database Errors Logging queries Adding a new Database Driver Models and Fields Fields Creating model tables Model options and table metadata Indexes and Constraints Non-integer Primary Keys, Composite Keys Helper Security and SQL Injection API Documentation Database Query-builder Fields Schema Manager Model Query-builder Internals Constants and Helpers SQLite Extensions Getting started APIs Additional0 码力 | 347 页 | 380.80 KB | 1 年前3
peewee Documentation Release 3.4.0Installing with git Running tests Optional dependencies Skip Compilation of SQLite Extensions Quickstart Model Definition Storing data Retrieving Data Closing the database Working with existing databases What example Diving into the code More examples Contributing Patches Bugs Questions Query Examples Model Definitions Schema Creation Basic Exercises Joins and Subqueries Modifying Data Aggregation Recursion queries Adding a new Database Driver Models and Fields Fields Field-naming conflicts Creating model tables Model options and table metadata Indexes and Constraints Non-integer Primary Keys, Composite Keys0 码力 | 349 页 | 382.34 KB | 1 年前3
共 16 条
- 1
- 2













