I currently have a mysql database that is defined using pydal and used by several other applications. I am trying to use Web2py to create an interface with the existing database.
For testing I mirrored the schema of the database using sqlite and now that the project is ready I want to connect it to the mysql database, but I'm receiving the following error when trying to query the database from the controller: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. Traceback (most recent call last): File "/Users/jon/github/build/web/gluon/restricted.py", line 219, in restricted exec(ccode, environment) File "/Users/jon/github/build/web/applications/project/controllers/scenarios.py" <http://localhost:8000/admin/edit/cerebro/controllers/scenarios.py>, line 349, in <module> File "/Users/jon/github/build/web/gluon/globals.py", line 414, in <lambda> self._caller = lambda f: f() File "/Users/jon/github/build/web/gluon/tools.py", line 3981, in f return action(*a, **b) File "/Users/jon/github/build/web/applications/ <http://localhost:8000/admin/edit/cerebro/controllers/scenarios.py>project <http://localhost:8000/admin/edit/cerebro/controllers/scenarios.py>/controllers/scenarios.py" <http://localhost:8000/admin/edit/cerebro/controllers/scenarios.py>, line 207, in show use_case_set = list({row.use_case_name for row in mysql_db(mysql_db.build_scenarios).select()}) File "/Users/jon/.env/build/lib/python2.7/site-packages/pydal/objects.py", line 2250, in select return adapter.select(self.query, fields, attributes) File "/Users/jon/.env/build/lib/python2.7/site-packages/pydal/adapters/base.py", line 762, in select return self._select_aux(sql, fields, attributes, colnames) File "/Users/jon/.env/build/lib/python2.7/site-packages/pydal/adapters/base.py", line 718, in _select_aux rows = self._select_aux_execute(sql) File "/Users/jon/.env/build/lib/python2.7/site-packages/pydal/adapters/base.py", line 712, in _select_aux_execute self.execute(sql) File "/Users/jon/.env/build/lib/python2.7/site-packages/pydal/adapters/__init__.py", line 63, in wrap if not args[0].connection: File "/Users/jon/.env/build/lib/python2.7/site-packages/pydal/connection.py", line 36, in connection return getattr(THREAD_LOCAL, self._connection_uname_) AttributeError: 'thread._local' object has no attribute '_pydal_connection_4382647568_28651' To make things stranger, the query is sometimes successful on the first attempt after restarting the server, but a refresh always results in the error. Also using the web2py shell and loading the modules from the project, I am able to connect to the mysql database without error, and run the same query repeatedly without any issues. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.