Using a Python variable in MySQL query

前端 未结 2 1205
旧时难觅i
旧时难觅i 2020-12-21 13:05

I am trying to write a function that takes the variable written in the function placeholder() written below and then uses that in MySQL queries

相关标签:
2条回答
  • 2020-12-21 13:29
    sql = "TRUNCATE TABLE " + placeholder_variable + ";"
    cursor.execute(sql)
    
    0 讨论(0)
  • 2020-12-21 13:29

    SQL parameters cannot be used for metadata with MySQL. You will need to sanitize the value and substitute it normally.

    0 讨论(0)
提交回复
热议问题