0

I have a SQL query entered into a constant. One of the fields that I need to put in my where clause is USER which is a key word. To run the query I put the keyword into double quotes.

I have tried all of the suggestions from here yet none seem to be working.

Here is what I have for my constant:

SELECT_USER_SECURITY = "SELECT * FROM USER_SECURITY_TRANSLATED WHERE \"USER\" = '{user}' and COMPANY = " \
                       "'company_number'  and TYPE NOT IN (1, 4)"

I am not sure how to get this query to work from my constant.

I also tried wrapping the whole query in """. I am getting a key error on the USER.

SELECT_USER_SECURITY = """SELECT * FROM USER_SECURITY_TRANSLATED WHERE "USER" = '{user}' and
                          COMPANY = 'company_number'  and TYPE NOT IN (1, 4)"""

Below is the error I am getting:

nose.proxy.KeyError: 'user'
Community
  • 1
  • 1
DarthOpto
  • 1,640
  • 7
  • 32
  • 59

1 Answers1

0

So the triple quoted solution was the best one. The problem I was running into was I had not included the "user" key in my dictionary of params which formatted the query.

DarthOpto
  • 1,640
  • 7
  • 32
  • 59