This is a MySQL query that I want to use it inside a python script:
cmd = "mysql -Nr -uuser -ppwd -hlocalhost -P3307 mybase -e 'select value from table where Id='5' and product='product'" | tr -d ' ' | tr -d ',' | sed 's/>https:/>\r\nhttps:/g' | sed 's/=</=\n</g' | grep "https:" | sed 's;www.mysite.org/page/;;g' > /tmp/myfile.tmp"
After the Update it's look like this:
cmd = "mysql -Nr -uuser -ppwd -hlocalhost -P3307 mybase -e \' select value from table where Id="5" and product="product" \' | tr -d \' \' | tr -d \',\' | sed \'s/>https:/>\r\nhttps:/g\' | sed \'s/=</=\n</g\' | grep "https:" | sed \'s;www.mysite.org/page/;;g \' > /tmp/myfile.tmp"
The Result after the execution:
SyntaxError: invalid syntax
[root@admin tmp]$ vi select_python.py
[root@admin tmp]$ python select_python.py
What's wrong with my MySQL query Syntax inside the python script?