I have an sql table which i want to update based on a function this is my code so far:
def read(conn):
cursor = conn.cursor()
#cursor2 = conn.cursor()
cursor.execute("SELECT All [id],[keyword],[result],[status],[createddate] FROM [Table1].[dbo].[aa]")
index = 1
cursor.execute("set nocount on")
for row in cursor:
s = row[1]
s = re.sub(r'[^\w\s]', '', s)
a=do_func(s)
if a:
cursor.execute("update [Table1].[dbo].[aa] set status = 'completed', result = 'True' where id ={}".format(index))
else:
cursor.execute("update [Table1].[dbo].[aa] set status = 'completed', result = 'False' where id ={}".format(index))
if index == 10:
break
index += 1
i get pyodbc.ProgrammingError: No results. Previous SQL was not a query.
I added "set nocount on" but didn't solve i also tried making a second cursor but also didn't solve problem