from typing import List, Dict, Tuple
import sqlite3, csv

DB = 'restaurants.db'

# Helper function to run queries
def run_query(db: str, db_query: str, args: tuple = None) -> List[tuple]:
    """Return the results of running query db_query on database with name db.

    Optional query arguments for can be included in args.
    """
    
    con = sqlite3.connect(db)
    cur = con.cursor()
    
    if args is None: 
        cur.execute(db_query)
    else:
        cur.execute(db_query, args)

    data = cur.fetchall()
    cur.close()
    con.close()
    return data


# Fill out the function bodies below.
# You can use a combintion of SQL queries and Python code.
# But try to use more SQL than Python so you can practise it!

def avg_cost_city(db: str, city: str) -> int:
    """Return the average cost of a meal for a specified city in the
    restaurants table of database db.
    """
    # Add your code here   


def max_cost_cuisines(db: str) -> List[tuple]:
    """Return the maximum cost for all cuisines in database db.
    
    >>> max_cost_cuisines(DB)
    [('American', 23), ('Arabian', 12), ('Bakery', 23)...<continues>
    """
    # Add your code here   
    

def cuisine_max_cost(db: str) -> List[str]:
    """Return the one cuisine (inside a tuple) of the restaurant with the 
    greatest cost per meal.
    If there is a tie, provide all of the cuisines with the max cost.
    
    Precondition: there is at least one restaurant in the database.
    
    >>> cuisine_max_cost(DB)
    ['Brazilian', 'Burger', 'Lebanese', 'Mexican']
    """
    # Add your code here 
    
    # You may use additional python code after your query to 
    # get the correct list.
    

def most_cuisine_for_city(db: str, city: str) -> Tuple[str]:
    """Return the cuisine (inside a tuple) that appears the greatest number of 
    times for a specified city in database db. 
    If there is a tie, put all of the cuisines in a tuple
    
    >>> most_cuisine_for_city(DB, 'Pasay City')
    ['European']
    """
    # Add your code here 
    
    # You may use additional python code after your query to 
    # get the correct list.



if __name__ == '__main__':
    #print(avg_cost_city(DB, 'Brasilia'))
    #print(cuisine_max_cost(DB))
    #print(most_cuisine_for_city(DB, 'Pasay City'))
    #print(max_cost_cuisines(DB))
    
    pass