我有以下代码:
import pyodbc
conn = pyodbc.connect('DSN=QueryBuilder')
cursor = conn.cursor()
stringA = "SELECT GrantInformation.Call FROM GrantInformation"
cursor.execute(stringA)
rows = cursor.fetchall()
它运作良好多年,但突然间它已经停止了今天的工作与以下追溯:
Traceback (most recent call last):
File "C:/Users/nicholas/Desktop/test.py", line 6, in
cursor = conn.cursor()
AttributeError: 'NoneType' object has no attribute 'cursor'
该代码仍可在Jupyter Notebook中使用,但不再在外部工作,即在Pycharm / IDLE中
如果我在Pycharm中运行:
print(pyodbc.dataSources())
print(pyodbc.drivers())
我明白了:
none
none
如果我在Jupyter Notebook中这样做,我得到:
{'Visio Database Samples': 'Microsoft Access Driver (*.mdb, *.accdb)', 'dBASE Files': 'Mic