How i can extract data from DB to make a variable in discord.py

Viewed 16
    mydb = mysql.connector.connect(
  host='localhost',
  user='root',
  password='',
  database='levels'
)
cursor = mydb.cursor(dictionary=True)

That is my DB setup.

and that is the embed i want to show.

@bot.command()
async def bal(ctx):
  cursor.execute(f"SELECT ELO from users where ID = {ctx.author.id}")

  rows = cursor.fetchall()
  for row in rows: 
    usere = ctx.message.author.id
    embedis = discord.Embed(title="・                       ZELL | Professional League | User Profile                          ・",description=f"<@{usere}> Personal Info",color=0xc27c0e)
    embedis.add_field(name="Rank Statistics:", value="", inline=True)
    embedis.add_field(name=f"{ELO}")
    await ctx.send(embed=embedis)

How i can extract the ELO Table from DB to make it as a Variable there to use in (name=f"{ELO}")

1 Answers
ELO = cursor.execute(f"SELECT ELO from users where ID = {ctx.author.id}")

You can use this to get data for variables.

Related