Skip to content
Advertisement

Can’t update dictionary’s column in postgres DB because of double quotes?

I can update the column in question in two CLI commands:

That works just fine, but I am going to running the commands in python and doing something like subprocess.check_output(cli_0 + ” & ” + cli_1, shell=True) results in thinking the second is a bash command. I would ideally like to run something like:

But the double quotes in the dictionary kinda kills that idea. Turning them into single quotes also doesn’t work. Any suggestions would be incredibly helpful. I have access to python3.5 and I can’t pip install anything.

Advertisement

Answer

You should be able to backslash escape the inner double-quotes:

Otherwise, you can save to file and run it:

You should also be able to do a heredoc directly into psql:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement