cod_cli = df\['cod_cli'\].tolist()
cod_cli_str = ','.join(map(str, cod_cli))
\# clientesAtacado =
query = f"""
select \* from P_VTVVIEDB.VBRA_CITY
where bracityid in (select bracityid
from P_VTVVIEDB.VSW_ADDRESS
where swobjectid in (select swsiteid from P_VTVVIEDB.VSW_SITE where swcustomerid in
(SELECT swcustomerid FROM P_VTVVIEDB.VSW_CUSTOMER WHERE CONCAT('40',left(TELCNPJ,8)) IN (${cod_cli_str}))))
;
my return the query it's this:
Bad character in format or data of SW_CUSTOMER.TELCNPJ.
at gosqldriver/teradatasql.formatError ErrorUtil.go:85
# assume cod_cli as list of strings
cod_cli_str = ','.join(f"'{item}'" for item in cod_cli) #format each item as string literal
query = f"""
select * from P_VTVVIEDB.VBRA_CITY
where bracityid in (
select bracityid
from P_VTVVIEDB.VSW_ADDRESS
where swobjectid in (
select swsiteid
from P_VTVVIEDB.VSW_SITE
where swcustomerid in (
SELECT swcustomerid
FROM P_VTVVIEDB.VSW_CUSTOMER
WHERE CONCAT('40', left(TRIM(TELCNPJ), 8)) IN (${cod_cli_str})
)
)
);
TELCNPJ
is a string or converted/cast to a stringCONCAT('40', left(TELCNPJ, 8))
result has to match format of values in cod_cli_str
TRIM
to remove unexpected white space [you can choose to handle more unexpected values]