title: Peewee: how to pass raw SQL query parameter without apostrophes
body: <p>Using Python &amp; Peewee, I want to create a function that takes a SQL view name as an argument and returns its results. To avoid any unwanted SQL injections, I want to pass the view name as the SQL query parameter:</p>
  <pre class="lang-py prettyprint-override"><code>def run_view_query(view_name: str):
      query = BaseModel.raw(&quot;SELECT * FROM %s&quot;, view_name)
      return query
  </code></pre>
  <p>The problem is that Peewee automatically adds apostrophes around the keyword, so I'm getting the following error:</p>
  <pre class="lang-bash prettyprint-override"><code>peewee.ProgrammingError: syntax error at or near &quot;'vw_all_users'&quot;
  LINE 1: SELECT * FROM 'vw_all_users'
  </code></pre>
  <p>I know I can do it using python f-string like this:</p>
  <pre class="lang-py prettyprint-override"><code>query = BaseModel.raw(f&quot;SELECT * FROM {view_name}&quot;)
  </code></pre>
  <p>but then I'd have to do some regex validation for the possible threat of SQL injections. Is there any better solution for that?</p>