-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistAll.py
More file actions
26 lines (24 loc) · 856 Bytes
/
Copy pathlistAll.py
File metadata and controls
26 lines (24 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sqlite3
from colorama import Fore, Style
def listAll():
conn = sqlite3.connect("example.db")
cursor = conn.cursor()
check_table_exist = cursor.execute('''
SELECT EXISTS (
SELECT 1 FROM sqlite_master WHERE type='table' AND name='users'
);
''').fetchone()[0]
if check_table_exist:
conn = sqlite3.connect("example.db")
cursor.execute('''
SELECT * FROM users;
''')
names_rows = cursor.fetchall()
conn.close()
print(Fore.BLUE + "TODOS OS USUÁRIOS:\n")
for row in names_rows:
print(row)
print("")
else:
print(Fore.RED + "Não existe nenhuma tabela criada ainda, selecione a opção 1 no Menu principal para adicionar o primeiro usuário" + Style.RESET_ALL)
print("")