(x-post from stackoverflow: http://stackoverflow.com/questions/31371462/web2py-cant-connect-to-mssql-via-pypyodbc-but-possible-to-connect-from-idle)
I can connect via 'naked' pypyodbc, but not via the web2py DAL. I installed pypyodbc as per these instructions: https://code.google.com/p/pypyodbc/wiki/Linux_ODBC_in_3_steps In my web2py model I have: import pypyodbc # ps. Anthony informs me there is no need for this. px = DAL('mssql4://username:password@url,portnumber/databasename') In my controller I then have: def index(): return dict(message=(px.executesql('SELECT top 1 * FROM table;'))) Which gives me a ticket with the following traceback: Traceback (most recent call last): File "/home/andreas/web2py_project/web2py/gluon/restricted.py", line 227, in restricted exec ccode in environment File "/home/andreas/web2py_project/web2py/applications/welcome/models/db.py", line 95, in <module> px = DAL('mssql4://UID:password@URL,port/database') File "/home/andreas/web2py_project/web2py/gluon/packages/dal/pydal/base.py", line 174, in __call__ obj = super(MetaDAL, cls).__call__(*args, **kwargs) File "/home/andreas/web2py_project/web2py/gluon/packages/dal/pydal/base.py", line 459, in __init__ raise RuntimeError("Failure to connect, tried %d times:\n%s" % (attempts, tb)) RuntimeError: Failure to connect, tried 5 times: Traceback (most recent call last): File "/home/andreas/web2py_project/web2py/gluon/packages/dal/pydal/base.py", line 437, in __init__ self._adapter = ADAPTERS[self._dbname](**kwargs) File "/home/andreas/web2py_project/web2py/gluon/packages/dal/pydal/adapters/base.py", line 57, in __call__ obj = super(AdapterMeta, cls).__call__(*args, **kwargs) File "/home/andreas/web2py_project/web2py/gluon/packages/dal/pydal/adapters/mssql.py", line 106, in __init__ if do_connect: self.find_driver(adapter_args,uri) File "/home/andreas/web2py_project/web2py/gluon/packages/dal/pydal/adapters/base.py", line 188, in find_driver raise RuntimeError("no driver available %s" % str(self.drivers)) RuntimeError: no driver available ('pyodbc',) Which I find I weird, since I try to use pypyodbc, and not pyodbc. (I tried to import pypyodbc as pyodbc btw, same result). If I open a python prompt I can do this: import pypyodbc cnxn = pypyodbc.connect('Driver=FreeTDS; Server=url; port= portnumber; uid=username; pwd=password;database=database') cursor = cnxn.cursor() cursor.execute("select top 1 * from a_table where a_date > getdate() order by newid()") rows = cursor.fetchall() for row in rows: print row Which then outputs the desired single random row. So either web2py DAL is broken (not likely) or I am doing something wrong? p.s. Web2py version: 2.11.2-stable+timestamp.2015.05.30.16.33.24 (Running on Rocket 1.2.6, Python 2.7.6) -- 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.

