I am passing about 80k parameters but while executing the query, it seems like pyodbc
or SQL
is truncating the total number of parameters. It works when I pass around 2k parameters but fails anything above 2k. Below is my queries and I will highly appreciate your help.
contact_lst = df_attempt_filtered['Contact ID'].unique()
len(contact_lst) ### Prints: 80871
query_contact = """
SELECT DISTINCT
con.CONTACT_ID,
con.JOB_ROLE,
con.JOB_FUNCTION,
con.MAIN_PHONE_NUM,
con.WORK_PHONE_NUM,
con.MOBILE_PHONE_NUM,
acc.EMPLOYEE_COUNT AS "EmpSize"
FROM
V_S_CONTACT_w_MOBILE_NUM AS con
LEFT JOIN
V_S_ACCOUNT_ALL_w_others as acc
ON CON.ACCOUNT_ID = ACC.ACCT_ID
WHERE
con.CONTACT_ID IN ({})""".format(", ".join(["?"]*len(contact_lst)))
df_contacts = pd.read_sql(query_contact, con=conn, params=contact_lst)
I'm getting the following error:
ProgrammingError: ('The SQL contains 15335 parameter markers, but 80871 parameters were supplied', 'HY000') During handling of the above exception, another exception occurred: