title: How to implement a specific SQL statement as a SQLAlchemy ORM query
body: <p>I was following a tutorial to make my first Flask API (<a href="https://medium.com/@dushan14/create-a-web-application-with-python-flask-postgresql-and-deploy-on-heroku-243d548335cc" rel="nofollow noreferrer">https://medium.com/@dushan14/create-a-web-application-with-python-flask-postgresql-and-deploy-on-heroku-243d548335cc</a>) I did it but now I want to do queries more custom with SQLAlchemy and PostgreSQL. My question is how I could do something like this:</p>
  <pre><code>query = text(&quot;&quot;&quot;SELECT enc.*, persona.&quot;Persona_Nombre&quot;, persona.&quot;Persona_Apellido&quot;, metodo.&quot;MetEnt_Nombre&quot;, metodo_e.&quot;MetPag_Descripcion&quot; 
  FROM &quot;Ventas&quot;.&quot;Enc_Ventas&quot; AS enc 
  INNER JOIN &quot;General&quot;.&quot;Persona&quot; AS persona ON enc.&quot;PersonaId&quot; = persona.&quot;PersonaId&quot; 
  INNER JOIN &quot;Ventas&quot;.&quot;Metodo_Entrega&quot; AS metodo ON enc.&quot;MetodoEntregaId&quot; = metodo.&quot;MetodoEntregaId&quot;
  INNER JOIN &quot;General&quot;.&quot;Metodo_Pago&quot; AS metodo_e ON enc.&quot;MetodoPagoId&quot; = metodo_e.&quot;MetodoPagoId&quot; 
  INNER JOIN &quot;General&quot;.&quot;Estatus&quot; AS estado ON enc. &quot;&quot;&quot;)
  </code></pre>
  <p>but with SQLAlchemy in order to use the models that I created previously. Thanks in advance for any answer!!</p>
  <p>Edit:</p>
  <p>The columns that I wish to see at the final result are: enc.*, persona.&quot;Persona_Nombre&quot;, persona.&quot;Persona_Apellido&quot;, metodo.&quot;MetEnt_Nombre&quot;, metodo_e.&quot;MetPag_Descripcion&quot;</p>
  <p>I really wish I could share more info but sadly I can't at the moment.</p>