My code successfully sends a slack message from python using this function/code I Omitted the details of the code that are not relevant:
def post_to_slack():
(cursor initialized from query)
heading = [item[0] for item in cursor.description]
row1 = cursor.fetchone()
col_heads = "%-10s %-51s %-52s %s" % (heading[0],heading[1],heading[2],heading[3])
while row1:
vSecond = row[1][:30]
vThird = row[2][:30]
row_form = "%-14s %-41s %-39s %s" % (row1[0], vSecond, vThird, row1[3])
send_slack_messg(col_heads, webhook_url)
send_slack_messg(row_form, webhook_url)
row1 = cursor.fetchone()`
Again, the slack message is sent with no problems. The first row is formatted perfectly. The second row is similar to the first but slight shift in spacing in two or three of the column values. The 3rd row and beyond are significantly shifted by a random amount of spaces (not over 10 spaces but significant enough to not be a pleasant read.
Question: Is there a way to have my slack output be consistently formatted? Or is there a Python slack library that does this? Appreciate any help. Thx
I tried adjusting the format values of "%-Xs" - No success I tried using other formatting styles like "{} {} {} {}".format(...). Got worse or same results. Also tried enclosing with triple tics '''message''' still same issue.