I'm new to python. I'm trying to query a MSSQL database.
import pymssql
conn = pymssql.connect(host='hostname', user='username', password='password', database='dbname')
cursor = conn.cursor()
sql = "select count(*) from T_Email with (nolock) where Transmit is null"
cursor.execute(sql)
results = cursor.fetchall()
for row in results:
print (row)
The query successfully runs is Microsoft SQL Server Management Studio, but my python script always returns nothing.
I verified I have network connectivity. I verified the username, password and database name. If I change the password, then the script will give an error.
I have tried results = cursor.fetchone(), but that didn't help.
Any suggestions?