Skip to content

Instantly share code, notes, and snippets.

@detailyang
Last active December 20, 2015 08:09
Show Gist options
  • Save detailyang/6098103 to your computer and use it in GitHub Desktop.
Save detailyang/6098103 to your computer and use it in GitHub Desktop.
flask model
from flask.ext.sqlalchemy import SQLAlchemy
from app import db
class User(db.Model):
id = db.Column(db.Integer, primary_key = True)
username = db.Column(db.String(80), unique = True,
index = True, nullable = False)
email = db.Column(db.String(120), unique = True, nullable = False)
password = db.Column(db.String(100), nullable = False)
def __init__(self, **kwargs):
if 'username' in kwargs:
self.username = kwargs.pop('username')
if 'password' in kwargs:
self.username = kwargs.pop('password')
if 'email' in kwargs:
self.username = kwargs.pop('email')
def __str__(self):
return self.username
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment