Skip to content

Instantly share code, notes, and snippets.

@alexanderad
Created July 8, 2015 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexanderad/c4cb1befe576fc987b67 to your computer and use it in GitHub Desktop.
Save alexanderad/c4cb1befe576fc987b67 to your computer and use it in GitHub Desktop.
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