peewee Documentation Release 3.4.0begin 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() is_relative these are the tables and relationships: In order to create these models we need to instantiate a SqliteDatabase object. Then we define our model classes, specifying the columns as Field instances on the class peewee database instance -- our models will use this database to # persist information database = SqliteDatabase(DATABASE) # model definitions -- the standard "pattern" is to define a base model class # that0 码力 | 349 页 | 382.34 KB | 1 年前3
peewee Documentation
Release 3.5.0begin 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() is_relative these are the tables and relationships: In order to create these models we need to instantiate a SqliteDatabase object. Then we define our model classes, specifying the columns as Field instances on the class peewee database instance -- our models will use this database to # persist information database = SqliteDatabase(DATABASE) # model definitions -- the standard "pattern" is to define a base model class # that0 码力 | 347 页 | 380.80 KB | 1 年前3
peewee Documentation Release 3.1.0begin 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() is_relative these are the tables and relationships: In order to create these models we need to instantiate a SqliteDatabase object. Then we define our model classes, specifying the columns as Field instances on the class peewee database instance -- our models will use this database to # persist information database = SqliteDatabase(DATABASE) # model definitions -- the standard "pattern" is to define a base model class # that0 码力 | 332 页 | 370.77 KB | 1 年前3
peewee Documentation Release 3.0.0begin 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() is_relative these are the tables and relationships: In order to create these models we need to instantiate a SqliteDatabase object. Then we define our model classes, specifying the columns as Field instances on the class peewee database instance -- our models will use this database to # persist information database = SqliteDatabase(DATABASE) # model definitions -- the standard "pattern" is to define a base model class # that0 码力 | 319 页 | 361.50 KB | 1 年前3
peewee Documentation Release 3.6.0begin 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() class these are the tables and relationships: In order to create these models we need to instantiate a SqliteDatabase object. Then we define our model classes, specifying the columns as Field instances on the class peewee database instance -- our models will use this database to # persist information database = SqliteDatabase(DATABASE) # model definitions -- the standard "pattern" is to define a base model class # that0 码力 | 377 页 | 399.12 KB | 1 年前3
peewee Documentation Release 2.10.2begin 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() is_relative these are the tables and relationships: In order to create these models we need to instantiate a SqliteDatabase object. Then we define our model classes, specifying the columns as Field instances on the class peewee database instance -- our models will use this database to # persist information database = SqliteDatabase(DATABASE) # model definitions -- the standard "pattern" is to define a base model class # that0 码力 | 275 页 | 276.96 KB | 1 年前3
peewee Documentation Release 1.0.0“connect” step, rather than some arbitrary time later when a query is executed. >>> database = SqliteDatabase('stats.db') >>> database.connect() To use this database with your models, specify it in an inner multiple databases (provided that you don’t try and mix models from each): >>> custom_db = peewee.SqliteDatabase('custom.db') >>> class CustomModel(peewee.Model): ... whatev = peewee.CharField() ... . database object you wish to use, and then all your models will extend it: custom_db = peewee.SqliteDatabase('custom.db') class CustomModel(peewee.Model): class Meta: database = custom_db class0 码力 | 101 页 | 163.20 KB | 1 年前3
peewee Documentation Release 0.9.7database = SqliteDatabase('stats.db') >>> database.connect() It is possible to use multiple databases (provided that you don’t try and mix models from each): >>> custom_db = peewee.SqliteDatabase('custom database object you wish to use, and then all your models will extend it: custom_db = peewee.SqliteDatabase('custom.db') class CustomModel(peewee.Model): class Meta: database = custom_db class single connection per-thread, instantiate your database with threadlocals=True: concurrent_db = SqliteDatabase('stats.db', threadlocals=True) Deferring initialization Sometimes the database information0 码力 | 78 页 | 143.68 KB | 1 年前3
共 8 条
- 1













