connecting mysql database from pythonanywhere

871 views
Skip to first unread message

Rommel Sotto

unread,
Sep 25, 2015, 1:08:12 PM9/25/15
to Sahana-Eden
I am having this error when loading eden


I created the mysql databas in pythonanywhere and I did this setup in 000_config

settings.database.db_type = "mysql"


settings.database.database = "test$Sahana"

settings.database.username = "testusername"

settings.database.password = "a0b3c1d9ef"

Thanks



Pat Tressel

unread,
Sep 26, 2015, 2:45:11 AM9/26/15
to sahan...@googlegroups.com
Hi, Rommel!

Let me make sure I understand...  Is this what you've done so far?

-- Got an account on Pythonanywhere with username "test".
-- Created a Web2py service.
-- On the MySQL tab, entered database name Sahana (after the test$ that they put in by default), and the database username and password you chose.
-- Installed a copy of Eden into Web2py's applications directory.
-- Edited the configuration file.
-- Tried to start Eden.

Could you comment out the settings.database.host line and try again?  The Pythonanywhere instructions for MySQL show an example for Django that has no host specified, so it seems the database can be accessed as though it is on the same machine.

Did you see instructions that say the database is on a remote server?

-- Pat

Pat Tressel

unread,
Sep 26, 2015, 5:34:40 AM9/26/15
to sahan...@googlegroups.com
Could you comment out the settings.database.host line and try again?  The Pythonanywhere instructions for MySQL show an example for Django that has no host specified, so it seems the database can be accessed as though it is on the same machine.

Did you see instructions that say the database is on a remote server?

Ok, I found a mention of that in a recent post in the Pythonanywhere blog:

https://blog.pythonanywhere.com/115/

"MySQL database connection hostname

The official host name you should use for connecting to your account's MySQL database instance has changed from mysql.server to *yourusername*.mysql.pythonanywhere-services.com. This bypasses a part of our infrastructure that has started showing problems in recent weeks, and it should be much more efficient and reliable than the old way. The old hostname will continue to work, but we strongly advise you to move over to the new one."

And that actually clears things up.  It's not a web URL -- this is part of the MySQL connection string.  So it shouldn't have the https:// on it.  Try it like this:

settings.database.host = "test.mysql.pythonanywhere-services.com"

Here's the code that assembles the connection string:

https://github.com/flavour/eden/blob/master/modules/s3cfg.py#L876

You can see it's putting mysql:// on the front as the protocol.

-- Pat

Rommel Sotto

unread,
Sep 26, 2015, 11:45:29 PM9/26/15
to Sahana-Eden
Thanks that fixed it.

Pat Tressel

unread,
Sep 27, 2015, 10:47:30 AM9/27/15
to sahan...@googlegroups.com
Rommel --
 
Thanks that fixed it.

Yay!  ;-)

-- Pat

Pat Tressel

unread,
Sep 27, 2015, 11:57:56 PM9/27/15
to sahan...@googlegroups.com
Rommel --

Say, I'm wondering...how do you like Pythonanywhere?  I only know two people who've used it to run Eden.  They were just trying it out, and had the free accounts, which have resource limits.  Have you got a regular (paid) account? and does the performance seem ok?  Are you thinking of using it for a production system?

The two other folks also just used SQLite.  So I'm also wondering if you'd be willing to add a section to our wiki page about how to set up MySQL:

http://eden.sahanafoundation.org/wiki/InstallationGuidelines/PythonAnywhere

Any corrections or improvements to the other instructions would be very welcome, too!

;-)

-- Pat

Rommel Sotto

unread,
Sep 28, 2015, 2:30:50 AM9/28/15
to Sahana-Eden
Hi Pat

So far so good with pythonanywhere, easy to setup very straightforward (I can say because I have no background in IT whatsoever). I am running two Eden there, one I use as a production server, mostly using staff, warehouse and project module, though it will not be that much traffic since we are only about 10 people using it, and most of them are just viewing things only when needed (Bosses). The other I use to test things out mostly before I import data, or switch on and off functionality that I want before making the changes in the production server.


Regarding the wiki page I think I can come up with something though it will be very specific to how I setup the pythonanywhere MSQL as again I have no IT background most of which I just asked question and do some google search.

Thanks

Louiqa Raschid

unread,
Sep 28, 2015, 2:46:07 AM9/28/15
to Sahana-Eden
Rommel - Hi. You would be a great candidate to evaluate Pythonanywhere since we are indeed looking for solutions for non-developers who have NO or LIMITED background in Python. If you put together some instructions re: the basic installation I am happy to edit as needed. You will see that the current installations mentioned by Pat do not really discuss connecting to the MySQL database and that is the step where others may also encounter problems. It will be GREAT if you can help. Louiqa Raschid

Rommel Sotto

unread,
Sep 28, 2015, 5:12:34 AM9/28/15
to sahan...@googlegroups.com
Hi

I did some edits in the wiki page, kindly check.

One thing is it normally work for new installation, but when I tried it with an Eden that has already an admin account and some data it gives this error 

<class '_mysql_exceptions.IntegrityError'> (1452, 'Cannot add or update a child row: a foreign key constraint fails (`rommelsotto$edentest`.`auth_event`, CONSTRAINT `auth_event_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) ON DELETE CASCADE)')

The solution I have is to delete the sessions folder.

Thanks

--
You received this message because you are subscribed to a topic in the Google Groups "Sahana-Eden" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sahana-eden/wjGdwEdZK6Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sahana-eden...@googlegroups.com.
To post to this group, send email to sahan...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sahana-eden/c3c3820f-bfea-40a4-a214-04433b3dff9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages