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.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo