from my_functions import open_csvtest_db
from my_functions import close_database
from prettytable import PrettyTable

conn, cursor = open_csvtest_db()
sql = '''SELECT Embarked FROM titanic GROUP BY Embarked'''
cursor.execute(sql)
data = cursor.fetchall()
table1 = PrettyTable(['Embarked'])
for (embark) in data:
    table1.add_row([embark])
print(table1)

sql = '''SELECT Embarked, COUNT(*) FROM titanic GROUP BY Embarked'''
cursor.execute(sql)
data = cursor.fetchall()
table2 = PrettyTable(['Embarked', 'Count'])
for (embark, count) in data:
    table2.add_row([embark, count])
print(table2)
close_database(cursor, conn)