I have this Python script that calls a SQL command through the windows command prompt
UN1=str(sys.argv[1])
f_statement1 = """ set nocount on; set ansi_warnings off;
SELECT c.campaign_name,ca.campaign_id,ca.product_id,p.product_name
FROM [AN_MAIN].[dbo].[campaign_addon] ca
JOIN product p ON p.product_id = ca.product_id
JOIN campaign c ON c.campaign_id = ca.campaign_id
WHERE ca.campaign_id IN""" + str(UN1)
Here I'm using the 'IN' function for multiple variables meaning it must be in brackets and comma separated if there's more than one. In the command prompt I have to make my string call the file 'addon.py' and it looks like this:
addon.py (45123,51241)
So I'm forced to put my variables in brackets to make them one argument as far as python in concerned.
Is there a way to make the python take any number of variables without having to manually put the commas and brackets in?
i.e. addon.py 45123 51241