peewee Documentation Release 0.9.7TweetCount.update(count=F('count') + 1).where(user=charlie) You can use django-style syntax to create select queries: # how many active users are there? User.filter(active=True).count() # get tweets .. class Meta: ... database = custom_db ... >>> custom_db.connect() >>> CustomModel.create_table() Best practice: define a base model class that points at the database object you wish to Reading, Updating and Deleting Creating a new record You can use the Model.create() method on the model: >>> Blog.create(creator='Charlie', name='My Blog') <__main__.Blog object at 0x2529350> This0 码力 | 78 页 | 143.68 KB | 1 年前3
peewee Documentation Release 1.0.0TweetCount.update(count=F('count') + 1).where(user=charlie) You can use django-style syntax to create select queries: # how many active users are there? User.filter(active=True).count() # get tweets Tweet.filter(Q(user__is_staff=True) | Q(user__is_superuser=True)) You can use python operators to create select queries: # how many active users are there? User.select().where(User.active == True).count() .. class Meta: ... database = custom_db ... >>> custom_db.connect() >>> CustomModel.create_table() Best practice: define a base model class that points at the database object you wish to0 码力 | 101 页 | 163.20 KB | 1 年前3
peewee Documentation
Release 0.9.7update TweetCount.update(count=F(’count’) + 1).where(user=charlie) You can use django-style syntax to create select queries: # how many active users are there? User.filter(active=True).count() # get tweets CharField() ... ... class Meta: ... database = custom_db ... >>> custom_db.connect() >>> CustomModel.create_table() Best practice: define a base model class that points at the database object you wish to Creating a new record You can use the Model.create() method on the model: 6 Chapter 1. Contents: peewee Documentation, Release 0.9.7 >>> Blog.create(creator=’Charlie’, name=’My Blog’) <__main__.Blog0 码力 | 53 页 | 347.03 KB | 1 年前3
peewee Documentation
Release 2.0.2CharField() ... ... class Meta: ... database = custom_db ... >>> custom_db.connect() >>> CustomModel.create_table() Best practice: define a base model class that points at the database object you wish to Reading, Updating and Deleting Creating a new record You can use the Model.create() method on the model: >>> User.create(username=’Charlie’) <__main__.User object at 0x2529350> This will INSERT a new autocommit off when instantiating your database: db = SqliteDatabase(’:memory:’, autocommit=False) User.create(username=’somebody’) db.commit() 1.4.4 Non-integer Primary Keys and other Tricks Non-integer primary0 码力 | 65 页 | 315.33 KB | 1 年前3
peewee Documentation
Release 1.0.0update TweetCount.update(count=F(’count’) + 1).where(user=charlie) You can use django-style syntax to create select queries: # how many active users are there? User.filter(active=True).count() # get tweets Q(user__is_superuser=True)) 3 peewee Documentation, Release 1.0.0 You can use python operators to create select queries: # how many active users are there? User.select().where(User.active == True).count() CharField() ... ... class Meta: ... database = custom_db ... >>> custom_db.connect() >>> CustomModel.create_table() Best practice: define a base model class that points at the database object you wish to0 码力 | 71 页 | 405.29 KB | 1 年前3
peewee Documentation Release 3.0.0Bulk inserts Updating existing records Atomic updates Deleting records Selecting a single record Create or get Selecting multiple records Filtering records Sorting records Getting random records Paginating options, use: python runtests.py --help Note To run tests against Postgres or MySQL you need to create a database named “peewee_test”. To test the Postgres extension module, you will also want to install extension 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 anything0 码力 | 319 页 | 361.50 KB | 1 年前3
peewee Documentation Release 3.4.0Bulk inserts Updating existing records Atomic updates Deleting records Selecting a single record Create or get Selecting multiple records Filtering records Sorting records Getting random records Paginating options, use: python runtests.py --help Note To run tests against Postgres or MySQL you need to create a database named “peewee_test”. To test the Postgres extension module, you will also want to install extension 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 anything0 码力 | 349 页 | 382.34 KB | 1 年前3
peewee Documentation
Release 3.4.0options, use: python runtests.py --help Note: To run tests against Postgres or MySQL you need to create a database named “peewee_test”. To test the Postgres extension module, you will also want to install extension 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 anything the database that will store our data. This will create the tables with the appropriate columns, indexes, sequences, and foreign key constraints: db.create_tables([Person, Pet]) 1.2.2 Storing data Let’s0 码力 | 284 页 | 1.03 MB | 1 年前3
peewee Documentation
Release 3.3.0options, use: python runtests.py --help Note: To run tests against Postgres or MySQL you need to create a database named “peewee_test”. To test the Postgres extension module, you will also want to install extension 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 anything the database that will store our data. This will create the tables with the appropriate columns, indexes, sequences, and foreign key constraints: db.create_tables([Person, Pet]) 1.2.2 Storing data Let’s0 码力 | 280 页 | 1.02 MB | 1 年前3
peewee Documentation
Release 3.5.0Bulk inserts Updating existing records Atomic updates Deleting records Selecting a single record Create or get Selecting multiple records Filtering records Sorting records Getting random records Paginating options, use: python runtests.py --help Note To run tests against Postgres or MySQL you need to create a database named “peewee_test”. To test the Postgres extension module, you will also want to install extension 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 anything0 码力 | 347 页 | 380.80 KB | 1 年前3
共 16 条
- 1
- 2













