MySQL update table

    0

    2

    Python public recipes

    This code updates a column in a table with a specific value.

    Library: mysql-connector-python

    cursor = db.cursor() # db is created with mysql.connector.connect()
    stmt = "UPDATE table SET col_to_update=%s WHERE col_to_filter=%s"
    cursor.execute(stmt, (new_value, filter_value, ))
    db.commit()
    cursor.close()
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.