0

I want to show table with aligned columns but having issue with spaces, I am using tabulate module for displaying table

my code:(ignore the 3rd line of script)

cur = await self.bot.db.execute("SELECT inviter_name, normal, bonus, leaves, fake FROM totals WHERE guild_id = ?",(ctx.guild.id,))
res = await cur.fetchall()
rows=len(res)
t=tabulate(res)
emb=discord.Embed(title=f"Invite Leaderboard for {member.guild.name}", description=f"`{t}`", color=0xFFA500)
emb.set_thumbnail(url=member.guild.icon.url)
await ctx.send(embed=emb)

Output: here

desired Output: here

MySQL table(not the actual table, just for reference that it looks like this): here

I thought that if any spaces in names causing issue so for that I have searched over the internet to strip list having multiple tuples but haven't found any valuable lead yet.

I just wanna know if the length of the names causing spaces or if there anything wrong I am doing, if so then where

I don't know if this is of any help: length of first name is 14 and second name is 8 and I am using varchar datatype for names

Killua
  • 1
  • 1
  • 1

1 Answers1

0

The only way I found was with the library "table2ascII", however it does not have wrapping (multiline) like tabulate, so if your column size is too big it won't fit in Embed.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 07 '22 at 09:39