0

I am trying to select a query in mysql where the employee_id is a number from a list of values. Below is the query that I thought should work.

import mysql.connector
employee_id_list = [10,15]
sql = "select value, employee_id " \
"from employee_table " \
"where employee_id in %s "    

df = pd.read_sql(sql,conn,params=[tuple(employee_id_list)])

However, it produces the following error:

Python type tuple cannot be converted

Is there a way to make this work?

MathiasRa
  • 825
  • 2
  • 12
  • 24
  • 2
    Is `tupple` a typo? do not name your list as `list` – mad_ Feb 26 '19 at 20:36
  • I suggest looking at https://github.com/kennethreitz/records which might make your development easier. – Keith John Hutchison Feb 26 '19 at 20:38
  • Possible duplicate of [imploding a list for use in a python MySQLDB IN clause](https://stackoverflow.com/questions/589284/imploding-a-list-for-use-in-a-python-mysqldb-in-clause) – GMB Feb 26 '19 at 20:53

0 Answers0