peewee Documentation Release 0.9.7SqliteDatabase('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.db') >>> class . whatev = peewee.CharField() ... ... class Meta: ... database = custom_db ... >>> custom_db.connect() >>> CustomModel.create_table() Best practice: define a base model class that points then all your models will extend it: custom_db = peewee.SqliteDatabase('custom.db') class CustomModel(peewee.Model): class Meta: database = custom_db class Blog(CustomModel): creator = peewee0 码力 | 78 页 | 143.68 KB | 1 年前3
peewee Documentation Release 1.0.0rather 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 “Meta” class: custom_db = peewee.SqliteDatabase('custom.db') >>> class CustomModel(peewee.Model): ... whatev = peewee.CharField() ... ... class Meta: ... database = custom_db ... >>> custom_db.connect() then all your models will extend it: custom_db = peewee.SqliteDatabase('custom.db') class CustomModel(peewee.Model): class Meta: database = custom_db class Blog(CustomModel): creator = peewee0 码力 | 101 页 | 163.20 KB | 1 年前3
peewee Documentation Release 3.4.0extension in the postgres test database: -- install the hstore extension on the peewee_test postgres db. CREATE EXTENSION hstore; Optional dependencies Note To use Peewee, you typically won’t need anything by running import sqlite3 in the Python console. If you wish to use another database, there are many DB-API 2.0-compatible drivers out there, such as pymysql or psycopg2 for MySQL and Postgres respectively peewee import * db = SqliteDatabase('people.db') class Person(Model): name = CharField() birthday = DateField() is_relative = BooleanField() class Meta: database = db # This model uses0 码力 | 349 页 | 382.34 KB | 1 年前3
peewee Documentation
Release 3.3.0extension in the postgres test database: -- install the hstore extension on the peewee_test postgres db. CREATE EXTENSION hstore; 1.1.3 Optional dependencies Note: To use Peewee, you typically won’t need by running import sqlite3 in the Python console. If you wish to use another database, there are many DB-API 2.0-compatible drivers out there, such as pymysql or psycopg2 for MySQL and Postgres respectively import * db = SqliteDatabase('people.db') class Person(Model): name = CharField() birthday = DateField() is_relative = BooleanField() class Meta: database = db # This model uses the "people.db" database0 码力 | 280 页 | 1.02 MB | 1 年前3
peewee Documentation
Release 3.4.0extension in the postgres test database: -- install the hstore extension on the peewee_test postgres db. CREATE EXTENSION hstore; 1.1.3 Optional dependencies Note: To use Peewee, you typically won’t need by running import sqlite3 in the Python console. If you wish to use another database, there are many DB-API 2.0-compatible drivers out there, such as pymysql or psycopg2 for MySQL and Postgres respectively import * db = SqliteDatabase('people.db') class Person(Model): name = CharField() birthday = DateField() is_relative = BooleanField() class Meta: database = db # This model uses the "people.db" database0 码力 | 284 页 | 1.03 MB | 1 年前3
peewee Documentation Release 3.1.0extension in the postgres test database: -- install the hstore extension on the peewee_test postgres db. CREATE EXTENSION hstore; Optional dependencies Note To use Peewee, you typically won’t need anything by running import sqlite3 in the Python console. If you wish to use another database, there are many DB-API 2.0-compatible drivers out there, such as pymysql or psycopg2 for MySQL and Postgres respectively peewee import * db = SqliteDatabase('people.db') class Person(Model): name = CharField() birthday = DateField() is_relative = BooleanField() class Meta: database = db # This model uses0 码力 | 332 页 | 370.77 KB | 1 年前3
peewee Documentation Release 3.0.0extension in the postgres test database: -- install the hstore extension on the peewee_test postgres db. CREATE EXTENSION hstore; Optional dependencies Note To use Peewee, you typically won’t need anything by running import sqlite3 in the Python console. If you wish to use another database, there are many DB-API 2.0-compatible drivers out there, such as pymysql or psycopg2 for MySQL and Postgres respectively peewee import * db = SqliteDatabase('people.db') class Person(Model): name = CharField() birthday = DateField() is_relative = BooleanField() class Meta: database = db # This model uses0 码力 | 319 页 | 361.50 KB | 1 年前3
peewee Documentation
Release 3.5.0extension in the postgres test database: -- install the hstore extension on the peewee_test postgres db. CREATE EXTENSION hstore; Optional dependencies Note To use Peewee, you typically won’t need anything by running import sqlite3 in the Python console. If you wish to use another database, there are many DB-API 2.0-compatible drivers out there, such as pymysql or psycopg2 for MySQL and Postgres respectively peewee import * db = SqliteDatabase('people.db') class Person(Model): name = CharField() birthday = DateField() is_relative = BooleanField() class Meta: database = db # This model uses0 码力 | 347 页 | 380.80 KB | 1 年前3
peewee Documentation
Release 3.5.0extension in the postgres test database: -- install the hstore extension on the peewee_test postgres db. CREATE EXTENSION hstore; 1.1.3 Optional dependencies Note: To use Peewee, you typically won’t need by running import sqlite3 in the Python console. If you wish to use another database, there are many DB-API 2.0-compatible drivers out there, such as pymysql or psycopg2 for MySQL and Postgres respectively import * db = SqliteDatabase('people.db') class Person(Model): name = CharField() birthday = DateField() is_relative = BooleanField() class Meta: database = db # This model uses the "people.db" database0 码力 | 282 页 | 1.02 MB | 1 年前3
peewee Documentation Release 2.10.2by running import sqlite3 in the Python console. If you wish to use another database, there are many DB-API 2.0-compatible drivers out there, such as pymysql or psycopg2 for MySQL and Postgres respectively peewee import * db = SqliteDatabase('people.db') class Person(Model): name = CharField() birthday = DateField() is_relative = BooleanField() class Meta: database = db # This model uses uses the "people.db" database. Note Note that we named our model Person instead of People. This is a convention you should follow – even though the table will contain multiple people, we always name0 码力 | 275 页 | 276.96 KB | 1 年前3
共 16 条
- 1
- 2













