Created
July 8, 2015 10:19
-
-
Save alexanderad/c4cb1befe576fc987b67 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from peewee import * | |
database = SqliteDatabase(':memory:') | |
class Model(Model): | |
class Meta: | |
database = database | |
class User(Model): | |
username = CharField() | |
User.create_table() | |
User.create(username="foo") | |
print User.select().count() # prints 1 | |
user = User.select(User.username).first() | |
user.username = "bar" | |
user.save() # this one generates INSERT instead of UPDATE | |
print User.select().count() # prints 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment