title: How to create a postgres user with sqlalchemy
body: <p>I need to allow the creation of database users/roles through a web application that uses Python and SQLAlchemy in the backend.</p>
  <p>To do that i'm using something like:</p>
  <pre class="lang-py prettyprint-override"><code>sql = 'CREATE USER :username WITH PASSWORD :passwd'
  sql_data = {
      &quot;username&quot;: &quot;the_user_name&quot;,
      &quot;passwd&quot;: &quot;the_password&quot;,
  }
  request.db.execute(sql, sql_data)
  </code></pre>
  <p>But the SQL created by this query is:</p>
  <pre class="lang-sql prettyprint-override"><code>CREATE USER 'the_user_name' WITH PASSWORD 'the_password'
  </code></pre>
  <p>and what I need is:</p>
  <pre class="lang-sql prettyprint-override"><code>CREATE USER &quot;the_user_name&quot; WITH PASSWORD 'the_password'
  </code></pre>
  <p>with the username properly escaped. Is there a way that SQLAlchemy can handle this or should I create the string manually? If so, how can I escape the user input name?</p>