Trying to figure out how to pass each string from my loop into SQL to loop through each country and create an excel file specific to each country (5 excel files each having there own specific country data). I found code that does a .join and IN() statement that worked, but that put all 5 countries in all 5 files.
Code:
import CX_Oracle
Import xlwt
country_list = ['PERU','GUATEMALA','BAHAMAS','BARBADOS']
for country in country_list:
SQL = "SELECT * from TABLE WHERE COUNTRY = %s" % country
cursor = con.cursor()
cursor.execute(SQL)
book = xlwt.Workbook()
sheet1 = book.add_sheet('Summary')
for i, row in enumerate(cursor):
for j, col in enumerate(row):
sheet1.write(i+1,j,col) #Starts pasting the data at row 2
book.save('Output_' + country + '.xls')
Error "PERU" Invalid character.