# 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 
      
      Python language logo

      Query MySQL database

      database
      mysql
      Python public recipes

      sample of query for MySQL

      Shortcut: mysql.query.select

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.