Integrity Error - Flask & SQLAlchemy
Okay, the reason for this is a bit tricky :)
The error message does indeed mean that this email address is already in the DB. But why the heck is this? Because the debug
flag tells the built-in server to also use the reloader. And this reloader basically makes the app run twice on the first start. You can see that in the output:
$ python2 server.pyworked * Running on http://127.0.0.1:5000/ * Restarting with reloaderNot Working
There are multiple ways to get around that. Quick'n'dirty would be to just disable the reloader:
app.run(debug=True, use_reloader=False)
A better way would be to not populate the test DB that way. Instead you could create a separate custom command using Flask's CLI.