python - How do I modify the DB from Flask without posting? -
i have small flask application displays number of items held in sqlite 3 database. have cron job runs every day , (should) insert new entries database.
i have created following function modify database:
def add_entry(name): statement = 'insert ....' g.db.execute(statement, [name]) g.db.commit()
however, when run receive:
runtimeerror: working outside of application context
how modify database without posting url?
you'll need create application context explained in flask documentation on subject. like
with app.app_context(): add_entry()
should trick.