0

I have a query which takes some input which will be used in IN operator of sql. Since IN operator takes a () which is a tuple in python, I am unable to give the input to the query as a tuple because my input tuple is like -> (296,). In this, I am not sure how to deal with the , inside the tuple because it causing an error.

my data for reference: https://www.db-fiddle.com/f/m4RoYpdKQXY5KcVgrfmApq/0

My query with python is as follow:

    query = '''
      SELECT timestamp as timestamp,
      id ,
      users
      FROM rc 
      WHERE  timestamp='{}' and id IN {}
     
    '''.format(timestamp, id_tuple)

    df = pd.read_sql(query, con=sql.engine)
   
sam
  • 438
  • 1
  • 4
  • 16

0 Answers0