вывод похож на
Я отобразил результат из базы данных в табличной форме, используя BeautifulTable Python. но результат неорганизован.
try:
connection = mysql.connector.connect(host='localhost',
database='testdb',
user='root',
password='Pooja@123')
cur= connection.cursor()
sql = "select ip,ports,services from output where date=now()"
number_of_rows = cur.execute(sql)
table=BeautifulTable()
table.set_style(BeautifulTable.STYLE_DOTTED)
table.column_headers=["ip","ports","services"]
table.column_alignments['ip'] = BeautifulTable.ALIGN_LEFT
table.column_alignments['ports'] = BeautifulTable.ALIGN_LEFT
table.column_alignments['services'] = BeautifulTable.ALIGN_RIGHT
row=cur.fetchall()
for r in row:
table.append_row(r)
print(table)