Query MySQL database

    0

    28

    databasemysql
    Python public recipes

    sample of query for MySQL

    Shortcut: mysql.query.select

    # db = mysql.connector.connect()
    result = []
    cursor = db.cursor()
    cursor.execute("SELECT field FROM table")
    for x in cursor.fetchall():
      result.append({"field": x[0]})
    cursor.close()
    return result 
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.