import sqlite3


def team_exists(teamname):
    """See if a team exists in the database or not. If yes, return 1,
      if not return 0."""
    array = (teamname,) # for sanitizing
    if teamname == 'grandstand':
        return 1
    
    dbconn = sqlite3.connect('saso.db')
    cursor = dbconn.cursor()
    
    cursor.execute('SELECT * from teams where team_name=?', array)
    if cursor.fetchone():
        dbconn.commit()
        dbconn.close()
        
        return 1 
    else:
        dbconn.commit()
        dbconn.close()
        
        return 0