title: flask sqlalchemy pass Database name as string
body: <p>I am developing a <a href="https://flask.palletsprojects.com/en/1.1.x/" rel="nofollow noreferrer">flask</a> app that communicate with SQL through <a href="https://www.sqlalchemy.org/" rel="nofollow noreferrer">sqlalchemy</a></p>
  
  <p>I have a simple question that I found no answer looking online, how can I pass a <code>database_name</code> through a <code>str()</code> to the request. As example:</p>
  
  <pre class="lang-py prettyprint-override"><code>    row_id = 1
  
      ### normal call
      row = User.query.filter_by(id = row_id).first_or_404()
  
      ### what I'd like to achieve
      database_name = User
      row = database_name.query.filter_by(id = row_id).first_or_404()
  </code></pre>
  
  <p>Of course I am getting </p>
  
  <blockquote>
    <p>AttributeError: 'str' object has no attribute 'query'</p>
  </blockquote>
  
  <p>but I'd like to know if there's a safe way to achieve this.</p>
  
  <p>Thank you very much in advance for any help!</p>