Last active
December 25, 2015 20:19
-
-
Save felipe-prenholato/7033845 to your computer and use it in GitHub Desktop.
__ indicates / in file name
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
# -*- coding: utf-8 -*- | |
from __future__ import (absolute_import, division, print_function, | |
unicode_literals) | |
import os | |
from flask import Flask | |
from flask.ext.sqlalchemy import SQLAlchemy | |
db = SQLAlchemy() | |
def create_app(): | |
app = Flask(__name__) | |
app.config.from_object(get_conf()) | |
db.init_app(app) | |
return app | |
def get_conf(): | |
local_settings_found = os.path.exists( | |
os.path.join(os.path.dirname(__file__), 'config', 'local.py') | |
) | |
default_env = 'local' if local_settings_found else 'base' | |
env = os.environ.get('FOO_SETTINGS', default_env) | |
return 'foo.config.%s.Configuration' % env |
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
# -*- coding: utf-8 -*- | |
from __future__ import (absolute_import, division, print_function, | |
unicode_literals) | |
from datetime import datetime | |
from security.app import db | |
class User(db.Model): | |
id = db.Column(db.Integer, primary_key=True) | |
msisdn = db.Column(db.String(20)) | |
email = db.Column(db.String(255), unique=True, nullable=False) | |
password = db.Column(db.String(255), nullable=False) | |
created = db.Column(db.DATETIME, default=datetime.utcnow, index=True) | |
updated = db.Column(db.DATETIME, default=datetime.utcnow, | |
onupdate=datetime.utcnow, index=True) |
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
>>> from foo.app import db | |
>>> db.metadata | |
MetaData(bind=None) | |
>>> db.metadata.__dict__ | |
{'tables': immutabledict({}), '_schemas': set([]), '_bind': None, '_sequences': {}, 'quote_schema': None, 'schema': None} | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment