[Flask] Problems with a flask tutorial

Alejo Arias alejoar at gmail.com
Wed Apr 6 03:44:20 EDT 2016


Hi Andreas,

I just quickly checked your code: you have to uncomment line 18 and comment
out line 17, as you are defining the app's config variables inside the same
file:

app = Flask(__name__)
> app.config.from_object(__name__)


Also, be careful with your DATABASE config setting, as you set it to
'/temp/flaskr.db' and the tutorial uses '/tmp/flaskr.db'.

Hope that helps.

Regards,
Alejo

On 6 April 2016 at 07:53, Andreas Dorfner <
andreas.dorfner at stud.hs-regensburg.de> wrote:

> Hi all,
>
> to save the data in a database, I'm trying to use flask. For my first
> steps with flask, I'm working with the following online tutorial:
>
> http://flask.pocoo.org/docs/0.10/tutorial/dbinit/
>
> The web server on Beaglebone Black (with running Debian on it) is still
> working, but I have problems with "Step3: Creating the Database". By doing
> the online tutorial step by step, normally it should be possible to create
> a database by starting up a Python shell and import and call a function
> like that:
>
> Running a python shell:
> root at beaglebone:~/flaskr# python
>
>  >>> from flaskr import init_db
>  >>> init_db()
>
> By doing so, I get the following error message:
>
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
>    File "flaskr.py", line 28, in init_db
>      with closing(connect_db()) as db:
>    File "flaskr.py", line 23, in connect_db
>      return sqlite3.connect(app.config['DATABASE'])
> KeyError: 'DATABASE'
>
> Does anybody have an idea why I get this error?
> Attached you can find the source code and the database schema.
>
> Many thanks for your help.
> Andreas
>
>
>
>
> ---
> Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
> https://www.avast.com/antivirus
>
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160406/4ba858f3/attachment.html>


More information about the Flask mailing list