I want to run a sql query in a server. And the query is too long, so I am not able to figure out how it should be broken down:
The query looks something like this:
return("usr/<path> -e 'select val1 from table_name where val2 = (select val3 f rom another_table where val = 'abc')'")
Also, I can't post the exact query as its related to my work. So now the issue is, if I run a select query which comes in a single line of the return statement, then the value gets returned successfully. But in case of this long query, I am getting Syntax errors as it gets psuhed to the next line. Also, the code has to be compatible with both Python version 2 and 3. Can someone please help?
You need to use triple quotes:
Something like:
Triple quoted strings maintain newlines.