这是一个脚本,用于通过文件散列分析文件的信誉。从Azure SQL数据库中获取文件哈希,并通过调用API进行分析,然后将结果再次输入到数据库中。我正在使用SQL Server的ODBC驱动程序17。
在将数据重新输入到数据库时出现错误。
# Scanning files def fileScan(): select_sql = "SELECT source_hash FROM [Downloads]" crsr.execute(select_sql) rows = crsr.fetchall() # Read all rows for row in rows: print(''.join(row)) response = vt.get_file_report(''.join(row)) time.sleep(15) source_hash = row md5 = json.dumps(response['results']['md5']) sha1 = json.dumps(response['results']['sha1']) sha256 = json.dumps(response['results']['sha256']) detections = json.dumps(response['results']['positives']) query = ( "UPDATE Downloads SET md5=(?), sha1=(?), sha256=(?), detections=(?)" "WHERE source_hash=(?)")