Skip to content Skip to sidebar Skip to footer

Web2py Won't Connect To Mssql

I'm unable to get web2py to connect to mssql. (Failure to connect, tried 5 times: 'NoneType' object has no attribute 'connect') My connectio

Solution 1:

I've just received a solution from Massimo Di Pierro on the Web2Py forum. He deduced the cause and provided a work around.

Not sure if the "import pyodbc" is needed. Once the driver was assigned it stayed, even after a restart of the server.

# Test if the mssql driver is assigned. Sets it up if it isn't.import pyodbc
from gluon.dal import MSSQLAdapter
ifnot (MSSQLAdapter.driver):
  MSSQLAdapter.driver = globals().get('pyodbc',None)

db = DAL('mssql://testUser:password@localhost/testDB')

Solution 2:

After confirming that your login is correct and that you have pyodbc installed, be sure that the connection string for the server is as follows if your db server name has a backslash in it (e.g. localhost\dbServerName):

db = DAL('mssql://testUser:password@localhost\dbServerName/testDB')

You can substitute the localhost with an IP Address as well.

Environment: Windows 7 Professional, 32-bit operating system SQL Server 2008 R2 connecting over a network Web2py: source code install version 2.4.6 stable pyodbc: pyodbc-3.0.5.win32-py2.7.exe Python 2.7.3

Post a Comment for "Web2py Won't Connect To Mssql"