1

Attempting to pass a list through a SQL query as follows:

tickerlist = ['AAPL US', 'GOOG US']

placeholders = ','.join('?' for i in range(len(tickerlist)))
qry = 'SELECT * FROM table WHERE ticker IN (%s)' % placeholders
data = pd.read_sql(qry, connection, params=tickerlist)

Receiving the error:

ProgrammingError: (mysql.connector.errors.ProgrammingError) Not all parameters were used in the SQL statement
[SQL: SELECT * FROM table WHERE ticker IN (?,?)]
[parameters: ('AAPL US', 'GOOG US')]
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
shujufenxishi
  • 53
  • 1
  • 5
  • You don't need to construct dynamic SQL like this whn using sqlalchemy. See the linked quesiton. – Barmar Oct 18 '21 at 20:43

0 Answers0