0

I am executing a query in python using cs.execute() and I have a bunch of like clauses which is throwing an error. Below is the query:

cs.execute("select * from "
"production.finance.invoice_transactions a "
"inner join production.core.merchant_info b "
"WHERE  a.status IN ( 'refundSettledSuccessfully', 'returnedItem' ) "
"AND b.mid_partner_id in (%s) "
"AND a.customer_profile_id LIKE 'W_%' "
"AND a.customer_profile_id NOT LIKE '%@%' "
"AND to_date(settle_time_local) between %s and %s "
"AND to_date(b.created_at) = %s ", (id, dt1, dt2, dt1))

I am getting the error at the lines where I have the like clause. I have confirmed this by removing the like clause and the query executes successfully. I am not sure how I can resolve this error. The error specifically says its due to the single quotes. Below is the error.

ValueError: unsupported format character ''' (0x27) at index 1754

Ravi
  • 659
  • 2
  • 10
  • 32

0 Answers0