I have a script with this command
/usr/bin/psql postgres -h localhost -U postgres -c "GRANT CONNECT ON DATABASE "famdb-develop" TO fullwood;"
When I ran it, I got this error:
ERROR: syntax error at or near "-"
LINE 1: GRANT CONNECT ON DATABASE famdb-develop TO fullwood;
How can I escape the dash in this command?
2
Answers
Looks like the quotes aren’t being passed down to PostgreSQL. You need to escape them by prefixing them with backslashes (
):
As you don’t have variables in your sql you could use single quotes