コード例 #1
0
def init_db():
    with app.app_context():
        db = get_db()
        with app.open_resource(DATABASE_SCHEMA, mode='r') as f:
            db.cursor().executescript(f.read())
        db.commit()
        if TESTING == 1:
            with app.open_resource(TEST_SCHEMA, mode='r') as f:
                db.cursor().executescript(f.read())
            db.commit()
    return True
コード例 #2
0
ファイル: __init__.py プロジェクト: Rosk/flasqlite
def init_db():
    """ Die Datenbank wird nach einem vordefinierten Schema generiert.Die Methode kann aufgerufen werden und erzeugt die
    sqlite DB nach dem in der Schemadatei genannten Schema."""
    with closing(connect_db()) as db:
        with app.open_resource('schema.sql') as f:
            db.cursor().executescript(f.read())
        db.commit()
コード例 #3
0
ファイル: manage.py プロジェクト: valeriayang/fall2017
def send_email(name, email):
    mail = Mail(app)
    msg = Message("Thank you for applying to WHACK!",
                  sender="*****@*****.**",
                  recipients=[email])
    msg.html = "<img src='cid:confirmation_email_header.png'/></html> <div> Hey " + name + ", </div><br></br> <div> Thank you for applying to WHACK Fall 2017! We are so excited that you're interested in joining us for WHACK, and we can't wait to read your application. You'll hear back from us with decisions in October. </div> <br></brs><div> Until then, please feel free to contact us at [email protected] if you have any comments or questions! </div><br></br> <div>Cheers, </div> <div> The WHACK Team </div> wellesleyhacks.org"
    with app.open_resource("confirmation_email_header.png") as fp:
        msg.attach("confirmation_email_header.png", "image/png", fp.read())
    mail.send(msg)
コード例 #4
0
ファイル: hello.py プロジェクト: leemoispace/fuzzyonlineflask
def send_email(to, subject, template, **kwargs):
    msg = Message(app.config['FLASKY_MAIL_SUBJECT_PREFIX'] + subject,sender=app.config['FLASKY_MAIL_SENDER'], recipients=[to])
    msg.body = render_template(template + '.txt', **kwargs)
    msg.html = render_template(template + '.html', **kwargs)
    with app.open_resource("static/"+to+".xlsx") as fp:
        msg.attach("static/"+to+".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fp.read())
    thr = Thread(target=send_async_email, args=[app, msg])
    thr.start()
    return thr
コード例 #5
0
ファイル: app.py プロジェクト: FyZzyss/stream
def get_resource_as_string(name, charset='utf-8'):
    with app.open_resource(name) as f:
        return f.read().decode(charset)
コード例 #6
0
ファイル: server.py プロジェクト: hurti9/web-charm
def init_db():
    with closing(database_helper.connect_db()) as db:
        with app.open_resource('schema.sql', mode='r') as f:
            db.cursor().executescript(f.read())
        db.commit()
コード例 #7
0
ファイル: flaskr.py プロジェクト: Joyme20/flask
def init_db():
    with app.app_context():
        db = get_db()
        with app.open_resource('schema.sql', mode='r') as f:
            db.cursor().executescript(f.read())
        db.commit()
コード例 #8
0
ファイル: app.py プロジェクト: kimeuichan/WaterMelon
def init_db():
	with app.app_context():
		db = get_db()
		with app.open_resource('schema.sql', mode='r') as f:
			db.cursor().executescript(f.read())
		db.commit()
コード例 #9
0
ファイル: shoebox.py プロジェクト: kevinaxu/shoebox
def init_db():
    """Initializes the database."""
    db = get_db()
    with app.open_resource('schema.sql', mode='r') as f:
        db.cursor().executescript(f.read())
    db.commit()
コード例 #10
0
ファイル: db.py プロジェクト: phodal-archive/switch-pair
def init_db():
    """Initializes the database."""
    db = get_db()
    with app.open_resource('schema.sql', mode='r') as f:
        db.cursor().executescript(f.read())
    db.commit()