Python Forum

Full Version: Connection issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation

Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
>>> conn = pyodbc.connect('Driver={SQL Server};'
...                       'Server=ServerA;'
...                       'Database=TestDb;'
...                       'Trusted_Connection=yes;')
>>>
>>> cursor = conn.cursor()
>>> cursor.execute('SELECT * FROM TestDb.PatientAppointments')
Error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> pyodbc.ProgrammingError: ('42S02', "[42S02] [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'TestDb.PatientAppointments'. (208) (SQLExecDirectW)")
>>>
>>> for row in cursor:
...     print(row)
...