| 100 | |
| 101 | # View the table using a rich table |
| 102 | def table(): |
| 103 | cursor.execute("SELECT * from dbview") |
| 104 | records = cursor.fetchall() |
| 105 | try: |
| 106 | table = Table( |
| 107 | title=Panel(f'Query DB [red]{info["host"]}:{info["port"]}'), |
| 108 | show_header=True, |
| 109 | header_style="bold green", |
| 110 | ) |
| 111 | table.add_column("Name", style="purple", width=20) |
| 112 | table.add_column("Url", style="yellow") |
| 113 | table.add_column("Author", style="cyan") |
| 114 | table.add_column("Hash", style="dim") |
| 115 | table.add_column("Date", no_wrap=True, style="dim blue") |
| 116 | for record in records: |
| 117 | table.add_row( |
| 118 | record[0], record[1], record[2], record[3], str(record[4]) |
| 119 | ) |
| 120 | console.print(table) |
| 121 | except: |
| 122 | # Some terminals don't support rich |
| 123 | print("Name\t\t | URL\t\t | Channel\t\t | Hash\t\t | Date") |
| 124 | for record in records: |
| 125 | print( |
| 126 | f"{record[0]}\t\t | {record[1]}\t\t | {record[2]}\t\t | {record[3]}\t\t| {str(record[4])}\t\t" |
| 127 | ) |
| 128 | |
| 129 | # Edit a entry in the table |
| 130 | def edit(key, value): |