I have a fabfile that I would like to run a command to create a postgres database.
The SQL request is:
CREATE DATABASE "dbname"
WITH ENCODING = 'UTF8'
LC_COLLATE = 'en_US.UTF8'
LC_CTYPE = 'en_US.UTF8'
TEMPLATE = template0
OWNER = "dbowner";
I want to run it using:
from fabric.api import run
run("""sudo su postgres --command "psql -c 'REQUEST HERE'" """)
But I couldn't find any way of escaping it the right way.
Do you have any idea of how I could do it?