def __init__(self, user, password): # db.seesion.dispose() # db.session.recreate() app.config['SQLALCHEMY_DATABASE_URI'] = "%s://%s:%s@%s/%s" % ( DBTYPE, user, password, DBHOST, DBNAME) db = SQLAlchemy(app) # db.init_app(app) meta = db.MetaData(bind=db.engine)
from gdata.spreadsheets.client import SpreadsheetsClient from oauth2client.client import SignedJwtAssertionCredentials from gdata.gauth import OAuth2TokenFromCredentials app = Flask(__name__) try: import clb_config app.config.from_object('clb_config.Config') except: app.config.from_object(os.environ['APP_SETTINGS']) app.permanent_session_lifetime = timedelta(minutes=15) db = SQLAlchemy(app) meta = db.MetaData() meta.bind = db.engine activated_table = db.Table('activated_addresses', meta, db.Column('address', db.String, primary_key=True)) csrf = SeaSurf(app) import models login_manager = LoginManager() login_manager.init_app(app) login_manager.login_view = "login_page" assets = flask.ext.assets.Environment() assets.init_app(app)
import json from datetime import date, timedelta import time import sys parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, parentdir) APP_ROOT = os.path.dirname(os.path.abspath(__file__)) APP_STATIC = os.path.join(APP_ROOT, 'static') app = Flask(__name__) app.config.from_object('config') db = SQLAlchemy(app) metadata = db.MetaData(db.engine) cb_companies = db.Table('cb_companies', metadata, autoload=True) db.mapper(CBCompany, cb_companies) al_companies = db.Table('al_companies', metadata, autoload=True) db.mapper(ALCompany, al_companies) startup_info = db.Table('startup_info', metadata, autoload=True) db.mapper(StartupInfo, startup_info) precompanies = db.Table('precompanies', metadata, autoload=True) db.mapper(PreCompany, precompanies) oauth = OAuth() linkedin = oauth.remote_app( base_url = 'http://api.linkedin.com/v1/', name = 'linkedin', consumer_key = app.config['LINKEDIN_API_KEY'], consumer_secret = app.config['LINKEDIN_SECRET_KEY'],
from medline_journal import MedlineJournal from pubmed import FetchMedline from pubmed import Pubmed app = Flask(__name__) ## http://packages.python.org/Flask-SQLAlchemy/config.html ## how to adjust these parameters to make sure it won't timeout?? app.config['SQLALCHEMY_DATABASE_URI'] = "%s://%s:%s@%s/%s" % ( DBTYPE, DBUSER, DBPASS, DBHOST, DBNAME) app.config['SQLALCHEMY_POOL_SIZE'] = 10 ## default = 5 app.config['SQLALCHEMY_POOL_TIMEOUT'] = 50 ## default = 10 app.config['SQLALCHEMY_POOL_RECYCLE'] = 1800 # 30min db = SQLAlchemy(app) meta = db.MetaData(bind=db.engine) class Database(): def __init__(self, user, password): # db.seesion.dispose() # db.session.recreate() app.config['SQLALCHEMY_DATABASE_URI'] = "%s://%s:%s@%s/%s" % ( DBTYPE, user, password, DBHOST, DBNAME) db = SQLAlchemy(app) # db.init_app(app) meta = db.MetaData(bind=db.engine) @classmethod def connect(self, user, password): engine = create_engine("%s://%s:%s@%s/%s" %
DateTime = database.DateTime relationship = database.relationship backref = database.backref BINARY = database.BINARY class UnicodeMixIn(object): __table_args__ = {'mysql_charset': 'utf8'} @declared_attr def __tablename__(cls): return cls.__name__.lower() metadata = database.MetaData(database.engine) Base = declarative_base(metadata=metadata, metaclass=sqlamp.DeclarativeMeta) class UUID(TypeDecorator): """Platform-somewhat-independent UUID type Uses Postgresql's UUID type, otherwise uses BINARY(16), should be more efficient than a CHAR(32). Mix of http://stackoverflow.com/a/812363 and http://www.sqlalchemy.org/docs/core/types.html#backend-agnostic-guid-type """ impl = BINARY