def rmv_dupes_in_psumsdb(setoffilestoprocess, config):
setoffilestoprocess_fnames = [file.name for file in setoffilestoprocess]
constring = config['db_string']['db_string']
cnxn = pyodbc.connect(constring)
FilesToBeCrunched1000 = list(chunks(list(setoffilestoprocess_fnames), 2))
for FilesChunks1000 in FilesToBeCrunched1000:
sqlstring = 'DELETE FROM {0} WHERE [LOG] IN ('.format(config['db_string']['bd_psums_meta_table'])
# print((FilesChunks1000))
values_string = (', '.join("'" + item + "'" for item in FilesChunks1000))
sqlstring+=values_string
sqlstring+=')'
cnxn.execute(sqlstring)
The script calls this function but nothing happens on the database side. I wrote a function similar to this that does a Select statement and it works. But this one doesn't. I printed out (sqlstring
) and it correctly gave me the following output:
DELETE FROM [NSGWSAINLINE].[dbo].[bd_psums_meta] WHERE [LOG] IN ('0517312.002.7312-08.FRP.00.S25D._Yo9EXAOaDK6asQ2_.0.zip', '0503302.002.3302-20.FRP.00.S26A._obBBQu5GUT1pnKO_.0.zip')
DELETE FROM [NSGWSAINLINE].[dbo].[bd_psums_meta] WHERE [LOG] IN ('0524222.002.4222-08.FRP.00.S25D._cH03BJws2g1pnKO_.0.zip', '0532722.002.2722-15.92FIP.00.S26A._hR10vpeCvpsonKO_.0.zip')
DELETE FROM [NSGWSAINLINE].[dbo].[bd_psums_meta] WHERE [LOG] IN ('0524282.002.4282-25.FRP.00.S25D._0sOzWcCcEptonKO_.0.zip')
I actually went ahead and copied the outputs above and they ran in SQL Server and did the delete statements. So why isn't this working from within Python?