I successfully uploaded my webapp onto webfaction, but I noticed, when using peewee to connect to a MySQL database on my webfaction account, I got this error:
Some background information: I created the MySQL database on webfaction, but currently it does not have any tables within it. I assumed that when you're using peewee you can create tables from within your program like so:
So I didn't bother adding anything to my empty MySQL database on my webfaction control panel, but I'm just confused as to why I received the error above. Can anyone step me through successfully connecting to my MySQL database on webfaction? Regards, Guled EDIT: Thank you Sean for your insight. I have included the exact errors from my error logs. I removed the timestamps for simplicity.
asked 01 Dec '15, 22:18 Guled |
Making a successful connection is exactly as you've shown in your example:
The error you've presented doesn't seem to be a connection error at all. If you can amend your question to include the full traceback leading up to the error, we might be able to assist further. answered 01 Dec '15, 22:31 seanf The question has now been edited and it includes the error log. Thank you for the heads up Sean.
(01 Dec '15, 23:29)
Guled
Based on that, I'd say the problem is simply that your
(01 Dec '15, 23:49)
seanf
I made sure that I called the function in my init.py file like so:
I have a models.py file and I imported 'models' into my init.py file. I don't think that's the case.
(02 Dec '15, 00:33)
Guled
Also, I'd like to mention that I never created the tables manually on webfaction (PHPmyadmin).
(02 Dec '15, 00:37)
Guled
Your "
(02 Dec '15, 00:59)
seanf
Sean, whenever you have time, please step me through this problem. I'm confused since I've developed my flask app, in the beginning, using nothing but a terminal and now that I'm moving an actual app and making it live, I just don't know where to start.
(02 Dec '15, 05:05)
Guled
Do you mean that, if you start the application explicitly from the terminal, then it works - but if it's started by Apache (through mod_wsgi), then it doesn't? If that's true, then Sean's explanation makes sense; it indicates that you're only executing the initialization when
(02 Dec '15, 08:36)
ryans ♦♦
Hey Ryan, thank you for the response. I think I have a good idea of who this works now. I followed your tutorial earlier on how to setup a simple flask app onto a webapp created on Webfaction, and I think I noticed something. So we know that name == 'main' doesn't run the application, I believe that wsgi.py is the file that runs the application ( correct me if I'm wrong). I'm trying to identify which file runs the flask app because I only want to run my models.py initialization code to create database tables only once. I'll keep debugging and let you know how it goes. Thank you both for the insight.
(02 Dec '15, 16:48)
Guled
Hey Ryan, it seemed to work when I moved the database initialization code, while also importing the models.py, in wsgi.py. Which I believe is the file that runs my application. This file was based off your tutorial on deploying a flask app.
(02 Dec '15, 17:09)
Guled
I still have some errors to fix here and there due to deprecations of some libraries of mine, but I'm very happy this worked out. Thank you Ryan and Sean!
(02 Dec '15, 17:10)
Guled
showing 5 of 10
show 5 more comments
|