Becoming really frustrated with Azure / MySQL and Azure API / Python - cannot connect reliably
Hello,
I am becoming more and more frustrated with trying to do what I think is a simple task:
I have created a MySQL database on Azure.
I have deployed a web API through Azure - it builds and launches, but of course is throwing 500's
I have written a simple python app that retrieves a url value, looks up another value using a query, and returns the result.
Yet, I am getting stuck with Error 32 - Broken Pipe, Connection reset by peer. This is stupid - what am I missing? I really appreciate the help here.
Here's the code of the Python app:
from flask import Flask, jsonify, request, make_response
from markupsafe import escape
import json
import requests
import time
from datetime import date
import mysql.connector
feadship = mysql.connector.connect(buffered=True, user="X@X", password="XXXXX", host="XXXXX.mysql.database.azure.com", port=3306, database="feadship")
mycursor = feadship.cursor()
app = Flask(name)
@Muhammad Shoaib .route('/')
def index():
return 'Index Page'
@Muhammad Shoaib .route('/api/<barcode>')
def get_sort(barcode):
upc = escape(barcode)
product_query = "SELECT tblsort_upc.Sort_id FROM feadship.tblsort_upc INNER JOIN tblproduct on tblsort_upc.tblsort_idtblproduct = tblproduct.idtblproduct where UPC_product =" + upc
try:
mycursor.execute(product_query)
myresult = mycursor.fetchone()
row_count = mycursor.rowcount
except:
row_count = 0
if row_count < 1:
result = "No UPC" + barcode
else:
result = myresult[0]
return 'Sort: %s' % result