Couldnt execute long sql statement in python?

Question:

I have defined my sql statement as follows ( note the line breaks)

  def getTankSystemIds():
        sql='select tt.TankSystemId,ts.sitecode,tt.productid ' 
            'from  [dbo].[TankSystems] tt' 
            'left join [dbo].sites ts on tt.siteid=ts.siteid where ts.companyid=8' 
            'and ProductId in (10,4,2,3,11,4)'
        cursor = connectDB()
        cursor.execute(sql)
        records = cursor.fetchall()

When calling this method, I get following error. I changed single quote to ” and ”’,””” but all gave same error
What Im doing wrong here?
I tried providing the sql statement in a single long line too. But same error

SyntaxError: Non-ASCII character 'xef' in file /Users/ratha/PycharmProjects/Processor/Utilities/DbConnector.py on line 86, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
Asked By: Ratha

||

Answers:

Is the SQL query being copy/pasted from somewhere or saved as UTF-8 encoding by another program? It has a Byte Order Mark (BOM) which is what the xef character is. ASCII doesn’t like that because it’s a Unicode thing.

Answered By: Alex W
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.