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
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()
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)
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
def get_resource_as_string(name, charset='utf-8'): with app.open_resource(name) as f: return f.read().decode(charset)
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()
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()
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()