Home How to read a SQL file with python with proper character encoding?
 Based on a few examples (here, here) I can use psycopg2 to read and hopefully run a SQL file from python (the file is 200 lines, and though runs quickly, isn't something I want to maintain in a python file). Here is the script to read and run the file: sql = open("sql/sm_bounds_current.sql", "r").read() curDest.execute(sql)  However, when I run the script, the following error is thrown: Error: syntax error at or near "ï»¿drop" LINE 1: ï»¿drop table dpsdata.sm_boundaries_current_dev;  As you can see, the first line in the script is to drop a table, but I'm not sure why the extra characters are being read, and can't seem to find a solution that might set the encoding of the file when reading it.