1

I am using QODBC Driver to connect to my Quickbooks Data. Until now, I was the QODBC directly in Power BI/Excel and QODBC works perfectly fine there. But today, I tried to connect to QODBC using python and it is giving me the following error enter image description here

The python code I am using is this

import pyodbc 

cn = pyodbc.connect('DSN=QuickBooks Data 64-Bit QRemote;')
cursor = cn.cursor()
cursor.execute("SELECT Top 10 Name FROM Customer")

for row in cursor.fetchall():
    print (row)

cursor.close()

cn.close() 

Can anyone see what's the reason for this error?

Mayank
  • 93
  • 1
  • 9

1 Answers1

2

After a lot of googling, I found the answer. I don't know why but the pyodbc.connect statement requires one more parameter i.e. "autocommit=True". So, the updated code now looks like this and it is working perfectly fine.

import pyodbc 

# pyodbc.pooling = False
cn = pyodbc.connect('DSN=QuickBooks Data 64-Bit QRemote',autocommit=True)
cursor = cn.cursor()
cursor.execute("SELECT Top 10 Name FROM Customer")

for row in cursor.fetchall():
    print (row)

cursor.close()

cn.close() 
Mayank
  • 93
  • 1
  • 9