1

I am trying to update a table from the Snowflake Connector in python to a Snowflake table;

update TABLE set X = 100 where Y = 'Applebee's'

To escape the single quote in the Snowflake UI, I would format the "where" clause to be

where Y = 'Applebee\'s'

Also tried:

where Y = 'Applebee''s'

However, no fix that I have tried is succeeding to workaround this error in python. Is there a way to do this from python, in a one step process, without any steps in Snowflake? I only care about workarounds from python.

agdeal
  • 103
  • 7
  • 1
    The standard in SQL is a double single quote: `'Applebees''s'`. I'm voting to close as a typo. – Gordon Linoff Feb 06 '21 at 17:12
  • Double quotes did not work. Additionally, backslash in Snowflake SQL works fine. – agdeal Feb 06 '21 at 17:12
  • . . You may have an issue with your application interface, but Snowflake definitely supports `''` to mean a single `'` within a string: https://docs.snowflake.com/en/sql-reference/data-types-text.html. – Gordon Linoff Feb 06 '21 at 17:26

1 Answers1

0

In all SQL, the only true way to avoid weird characters and not have to account for each possibility is to parametrized your sql calls either as some sort of stored procedure call or a parametrized call from your client - in this case python.

In general this means, never have a case where you are concatenating a sql string to the value of a where clause like you have above.

Here's an example of how to parametrize a statement in python here

Chuma
  • 714
  • 3
  • 7