<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def apply_sql_script(conn, fname):
 """ Apply the given SQL script to the database :param conn: a DB API 2 connection :param fname: full path to the creation script """

    sql = open(fname).read()
    try:
        # we cannot use conn.executescript which is non transactional
        for query in sql.split('\n\n'):
            conn.execute(query)
    except Exception:
        logging.error('Error executing %s' % fname)
        raise