Created
October 18, 2012 03:50
-
-
Save campo/3909770 to your computer and use it in GitHub Desktop.
Data Model: SQLAlchemy vs. MongoAlchemy
This file contains 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
# SQLAlchemy | |
class Prereg(db.Model): | |
id = db.Column(db.Integer, primary_key=True) | |
email = db.Column(db.String(120)) | |
fav_restaurant = db.Column(db.String(120)) | |
location = db.Column(db.String(120)) | |
reg_date = db.Column(db.DateTime) | |
def __init__(self, email, fav_restaurant, location, reg_date=None): | |
self.email = email | |
self.fav_restaurant = fav_restaurant | |
self.location = location | |
self.reg_date = datetime.utcnow() | |
def __repr__(self): | |
return_string = '<email: {0}, date: {1}>'.format(self.email, self.reg_date) | |
return return_string | |
# MongoAlchemy | |
class Prereg(db.Document): | |
id = db.IntField() | |
email = db.StringField() | |
fav_restaurant = db.StringField() | |
location = db.StringField() | |
reg_date = db.StringField() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment