'Attempting to optimize my rookie python and mysql code

I'm very new to python and wrote a script that works but would really like to get some input from the experts on the "correct" or "best" way to write the code.

In the code, I'm querying my local mysql database then making a call to see if a specific username is in use or not. I'm then writing back to the database

Everything works as is. I'm just not sure it's the best way. My next task will be to figure out how to make more than one call at a time (for another question).

from req import callReq
import json
from mysql.connector import Error
z = 0
connection = mysql.connector.connect(host='10.0.0.46',
                                         database='mydb',
                                         user='user',
                                         password='user')

while z < 50000:
    mycursor = connection.cursor()

    mycursor.execute("SELECT _id, email FROM members where ucheck is null limit 1")

    myresult = mycursor.fetchone()
    id = myresult[0]
    e = myresult[1]

    getreq = callReq(e)
    d = json.loads(getreq)
    status = d['message']

    print(d)
    sql = """UPDATE members SET ucheck =%s, email=%s WHERE _id =%s"""
    val = (status, address, id,)
    mycursor.execute(sql, val)
    connection.commit()

    z = z + 1


def callReq(e):
  import requests
  url = "https://somewebsite/checkUserName/"+str(e)
  payload = '{}'
  headers = {
    'Cookie': ''
  }
  response = requests.request("GET", url, headers=headers, data=payload)

  return response.text


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source