You would use something like this:
cnxn = pyodbc.connect(...)
cursor = cnxn.cursor()
cursor.execute(
"""
CREATE PROCEDURE MYPROCNAME
DECLARE vInHandle utl_file.file_type;
vNewLine VARCHAR2(250);
BEGIN
vInHandle := utl_file.fopen('PATH','FILE', 'R');
LOOP BEGIN
utl_file.get_line(vInHandle,vNewLine);
dbms_output.put_line(vNewLine);
EXCEPTION WHEN OTHERS THEN EXIT;
END;
END LOOP;
utl_file.fclose(vInHandle);
END fopen;
END MYPROCNAME;
""")
cnxn.commit()
cursor.execute("exec MYPROCNAME")
I didn't actually test this, but it should be something like that.
You can *try* putting it all into one string and executing it, but
there are a lot of databases that won't allow that.