import sqlite3


def execute_sql(dbfile,query,params=None):
    """Execute SQL against a SQLite file
    
    Args:
        dbfile: SQLite database file
        query: SQL query
        params: sequence of parameters
    
    Returns:
        list of matching rows
    """
    conn=sqlite3.connect(dbfile)
    conn.row_factory=sqlite3.Row
    c=conn.cursor()
    
    try:
        if params is None:
            c.execute(query)
        else:
            c.execute(query,params)
        res=c.fetchall()
    except sqlite3.OperationalError as e:
        print(e)
        res=None
    c.close()
    conn.commit()
    conn.close()
    return res