Python MySQLdb string substitution without added quotations

后端 未结 2 1764
隐瞒了意图╮
隐瞒了意图╮ 2021-01-21 03:16

I\'d like to use string substitution for a comma-separated list, such as:

query = \"\"\"SELECT id, name, image_id
           FROM users
           WHERE id IN (%         


        
2条回答
  •  醉话见心
    2021-01-21 03:44

    For me it worked this way:

    cursor.execute(sql, (pids_list,))
    

    and I made sure that elements of the pids_list are integers and not strings.

提交回复
热议问题