INNER CODE UNIT · Python
do_list_companies
infobyte/emploleaks · emploleaks.py:1859
def do_list_companies(self, args):
"""List all companies in the local database."""
cur = self.local_conn.cursor()
cur.execute("SELECT company_name FROM companies")
table = [['Companies']]
for row in cur:
table.append([row['company_name']])
if len(table) > 1:
tab = PrettyTable(table[0])
tab.add_rows(table[1:])
self.poutput(tab)
else:
log.error("There are no companies in the database. Use 'add_company' to add one.")
cur.close()