Server does not exist or access denied error connecting web2py to MS SQL server

128 views
Skip to first unread message

Steve Lyle

unread,
Aug 30, 2018, 4:49:01 PM8/30/18
to web2py-users
I've read the book & plenty else offered by up on the little pits available on Prof. Google.
And I just don't get it I guess.

I'm on a Windows 10 Pro x64 box
I'm running web2py from cmd as:
"""
cd c:\web2py
python web2py
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2018
Version 2.17.1-stable+timestamp.2018.08.06.01.02.56
Database drivers available: sqlite3, imaplib, pyodbc, pymysql
please visit:
starting browser...
"""

I do have python 2.7.15 installed as c:\python27; also have c:\anaconda3 installed but for this purposes I break anaconda by renaming the c:\anaconda3 to c:\X-anaconda3.
I validate that running python from cmd it is opening 2.7.15 as expected given the environment path.
-----------------
C:\web2py>python
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>import pypyodbc
>>> import pyodbc
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pyodbc
>>>
-----------------
Importing pypyodbc doesn't report any problems.
I believe the traceback below perfect proves 2.7.15 is running and expectedly calling the pypyodbc installed within 2.7.15.
Importing pyodbc shows the error demonstrated above even thought web2py reports it as an available driver.

I have no problems accessing the test DB from SSMS or other applications.
SQL server is dev edition 2017.

My web2py application is called 'init'.

Why does this configuration of pydal fail?
What more info can I offer you in this thread to get this fixed?
Any tips appreciated.



--- from applications\init\private\appconfig.ini ------
; db configuration
[db]
uri       = mssql://sa:blabla@localhost/test
migrate   = true
pool_size = 10  


----------------
Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 219, in restricted
    exec(ccode, environment)
  File "C:/web2py/applications/init/models/db.py", line 36, in <module>
    check_reserved=['all'])
  File "C:\web2py\gluon\packages\dal\pydal\base.py", line 170, in __call__
    obj = super(MetaDAL, cls).__call__(*args, **kwargs)
  File "C:\web2py\gluon\packages\dal\pydal\base.py", line 475, in __init__
    "Failure to connect, tried %d times:\n%s" % (attempts, tb)
RuntimeError: Failure to connect, tried 5 times:
Traceback (most recent call last):
  File "C:\web2py\gluon\packages\dal\pydal\base.py", line 455, in __init__
    self._adapter = adapter(**kwargs)
  File "C:\web2py\gluon\packages\dal\pydal\adapters\__init__.py", line 40, in __call__
    obj = super(AdapterMeta, cls).__call__(*args, **kwargs)
  File "C:\web2py\gluon\packages\dal\pydal\adapters\mssql.py", line 31, in __init__
    driver_args, adapter_args, do_connect, after_connection)
  File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 369, in __init__
    super(SQLAdapter, self).__init__(*args, **kwargs)
  File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 53, in __init__
    self.reconnect()
  File "C:\web2py\gluon\packages\dal\pydal\connection.py", line 172, in reconnect
    self.connection = self.connector()
  File "C:\web2py\gluon\packages\dal\pydal\adapters\mssql.py", line 81, in connector
    return self.driver.connect(self.cnxn, **self.driver_args)
  File "c:\Python27\lib\site-packages\pypyodbc.py", line 2454, in __init__
    self.connect(connectString, autocommit, ansi, timeout, unicode_results, readonly)
  File "c:\Python27\lib\site-packages\pypyodbc.py", line 2507, in connect
    check_success(self, ret)
  File "c:\Python27\lib\site-packages\pypyodbc.py", line 1009, in check_success
    ctrl_err(SQL_HANDLE_DBC, ODBC_obj.dbc_h, ret, ODBC_obj.ansi)
  File "c:\Python27\lib\site-packages\pypyodbc.py", line 987, in ctrl_err
    raise DatabaseError(state,err_text)
DatabaseError: (u'08001', u'[08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.')

Steve Lyle

unread,
Aug 31, 2018, 8:19:19 AM8/31/18
to web2py-users
--- edit 20180831 ---
In the light of the new morning I figured this much out.
Changes:

appconfig.ini---
[db]
connectionstring = mssql://DRIVER={FreeTDS};SERVER=localhost;DATABASE=etl_metadata;UID=sa;PWD=d0taCell1!
---


db.py---
db = DAL(configuration.get('db.connectionstring'))
---


result error---
Error: (u'IM002', u'[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified')
---

--- end edit ---
Reply all
Reply to author
Forward
0 new messages