Python error updating a SQL DB

后端 未结 2 1033
栀梦
栀梦 2021-01-26 10:36

I have some python code that looks like this

import pypyodbc
import pandas as pd
home=\"c:/SQL/\"
df = pd.read_sql_query(sql4, conn3
for y1 in range(0 , k):
            


        
相关标签:
2条回答
  • 2021-01-26 10:48

    In this case the correct Update statement is:

    cursor.execute("""UPDATE ENCOMPASS_DIA SET CTIME=? WHERE SERNUM=?""", (SSTIME,ARCHIVE_SERNUM ))
    
    0 讨论(0)
  • 2021-01-26 11:00

    An easy enough mistake to make.

     cursor.execute("""
            UPDATE ENCOMPASS_DIA
            SET CTIME=%s
            WHERE SERNUM=ARCHIVE_SERNUM
            """, (STIME, ))
    

    There should be a trailing , after the STIME or (STIME) will be interpreted as a list instead of a tuple.

    0 讨论(0)
提交回复
热议问题