Hi,
I am trying to access the same mysql database in a web2py app (which
created it) AND from a “stand-alone” python app (which primarily extracts
information from it).
I can access the the db from the web_2py app but access from the
stand-alone fails with “RuntimeError: 'Failure to connect, tried 5 times…”
Both apps are running on the same (macOS Sierra) system
What am I doing wrong?
Note below, the database definition is in file “mfm_media_model.py”
###
IN THE WEB2PY APP
###
>>> in appconfig.ini:
; db configuration
[db]
uri = mysql://root:password@localhost/mfm_curr_lib
migrate = true
pool_size = 10 ; ignored for sqlite
>>> in db.py:
db = DAL(myconf.get('db.uri'),
pool_size=myconf.get('db.pool_size'),
migrate_enabled=myconf.get('db.migrate'),
lazy_tables=True,
check_reserved=['all'])
!!! All works well !!!
####
IN THE STAND-ALONE APP:
####
>>> in mfm_media_model.py:
from pydal import DAL, Field
either
db = DAL('mysql://root:password@localhost/mfm_curr_lib', pool_size =
10)
or
db = DAL('mysql://root:password@localhost:3306/mfm_curr_lib',
pool_size = 10)
… produces
RuntimeError: 'Failure to connect, tried 5 times:\nTraceback (most recent
call last):\n File "/Library/Python/2.7/site-packages/pydal/base.py", line
455, in __init__\n self._adapter = adapter(**kwargs)\n File
"/Library/Python/2.7/site-packages/pydal/adapters/__init__.py", line 40, in
__call__\n obj = super(AdapterMeta, cls).__call__(*args, **kwargs)\n File
"/Library/Python/2.7/site-packages/pydal/adapters/base.py", line 373, in
__init__\n super(SQLAdapter, self).__init__(*args, **kwargs)\n File
"/Library/Python/2.7/site-packages/pydal/adapters/base.py", line 50, in
__init__\n self.find_driver()\n File
"/Library/Python/2.7/site-packages/pydal/adapters/base.py", line 101, in
find_driver\n str(self.drivers))\nRuntimeError: No driver of supported ones
(\'MySQLdb\', \'pymysql\', \'mysqlconnector\') is available\n'
module body in mfm_media_model.py at line 63
db = DAL('mysql://root:M4Msings@localhost:3306/mfm_curr_lib/', pool_size =
10)
function __call__ in base.py at line 170
obj = super(MetaDAL, cls).__call__(*args, **kwargs)
function __init__ in base.py at line 475
"Failure to connect, tried %d times:\n%s" % (attempts, tb)
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.