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, COUNT(*) FROM titanic WHERE Sex = 'female' GROUP BY Embarked HAVING COUNT(*) > 50'''
cursor.execute(sql)
data = cursor.fetchall()
table = PrettyTable(['Embarked', 'Count'])
for (embark, count) in data:
    table.add_row([embark, count])
print(table)
close_database(cursor, conn)