Forums

export DEV_DATA_BASE_URL is not working

I set up my environment variable,export DEV_DATA_BASE_URL=mysql://user:password@server/databasename, in my virtualenv console. I am working with Flask, in the virtuaIenv console I run python manager.py shell, and I was able to create the TABLES in my data base using db.create_all(). However, it seem that the value of the DATA_BASE_URL is missing when the app tries to connect to it when in production. I have the following error:

File "/home/masaguaro/.virtualenvs/my-virtualenv/lib/python3.4/site-packages/MySQLdb/connections.py", line 280, in query _mysql.connection.query(self, query) _mysql_exceptions.OperationalError: (2006, 'MySQL server has gone away')

How can I prevent this from happening ?

Hi there,

That's two separate issues.

  1. you won't be able to export in the console and get it to the webapp, because those are always on different servers. Go to our help page to see how to setup environment variables for webapps.

  2. this occurs if your app is holding an idle mysql connection open for a long time. if you are using sqlalchemy, set a pool_recycle time of <300s