2

I'm trying to connect to a DB using pyodbc.

This is my code:

import pyodbc as db
c_str = r'DRIVER={InterSystems ODBC35}; ' + 'SERVER={0}; PORT={1}; DATABASE={2};' \
                                              'UID={3}; PWD={4}; SQL_ACCESS_MODE=1'.format(
                                               server, port, database, user, pw)
    conn = db.connect(c_str, autocommit=True)

But I keep getting this error below in the traceback:

pyodbc.Error: ('HY000', '[HY000] [Cache ODBC][State : HY000][Native Code 417]\r\n[C:\\Program Files\\Anaconda3\\pythonw.exe]\r\nAccess Denied (417) (SQLDriverConnect); [HY000] [Cache ODBC][State : HY000][Native Code 417]\r\n[C:\\Program Files\\Anaconda3\\pythonw.exe]\r\nAccess Denied (417)')

Does anyone know what needs to be done? I've configured the DSN and the connection test was fine.

leyjl2
  • 29
  • 2
  • 2
    "I've configured the DSN and the connection test was fine." - So can you get a working connection using `pyodbc.connect("DSN=your_dsn_name;UID=xxx;PWD=yyy")` ? – Gord Thompson Aug 18 '21 at 18:58
  • I've managed to establish the connection now using the line you wrote :) – leyjl2 Aug 22 '21 at 17:32

0 Answers0