On my previous post, I’ve been working with Flask,SQLAlchemy, and Gnunicorn for some REST API.
Setting up virtualenv with the following pip requirements.
Flask==0.6.1 Flask-SQLAlchemy==0.11 Jinja2==2.5.5 LEPL==5.0.0 MySQL-python==1.2.3 SQLAlchemy==0.6.6 Werkzeug==0.6.2 distribute==0.6.10 gevent==0.13.4 greenlet==0.3.1 gunicorn==0.12.1 lockfile==0.9.1 wsgiref==0.1.2 yolk==0.4.1
The model.py:
from flask import Flask from flaskext.sqlalchemy import SQLAlchemy from sqlalchemy import Table, Column, Integer, String, Date, Float import config # DB class app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = config.DB_URI db = SQLAlchemy(app) # DB classess class Player(db.Model): __tablename__ = 'player' playerid = db.Column('playerid', Integer, primary_key=True) username = db.Column('username', String(30), unique=True) email = db.Column('email', String(50), unique=True) password = db.Column('password', String(100), unique=False) avatarid = db.Column('avatarid', Integer,default=1) language = db.Column('language', Integer,default=1) regdate = db.Column('regdate', Date) activation_key = db.Column('activation_key', String(60)) active = db.Column('active', Integer, default=0) def __init__(self, username=None, email=None,password=None): self.username = username self.email = email self.password = password def __repr__(self): return '<player %s %s>' % (self.username, self.email)