title: How do I return SQL table using Python API with Provided Parameter?
body: <p>I am trying to call an API to serve data from a MSSQL database. If I input only the endpoint without parameter, it successfully shows the error of missing param. When I insert param with wrong/unavailable id, it will show result as {&quot;data&quot;: []}. However, if I insert correct parameter into the ID, the error 500 occur. May I know where should I adjust so that I will be able to get the data from the table. Below is my codes for the endpoints.</p>
  <pre><code>from flask_restful import Resource
  from flask import request
  from sqlalchemy import create_engine
  from sqlalchemy.orm import scoped_session, sessionmaker
  import app_config
  
  
  class Test(Resource):
  
      def get(self):
  
  
          id = request.args.get(&quot;id&quot;, None)
  
          UGengine = create_engine(f'{app_config.SQL_SERVER_STRING}')
          UGSession = scoped_session(sessionmaker(bind=UGengine))
  
          s = UGSession()
  
          if id:
              query_data = s.execute(f&quot;SELECT * FROM [DBName].[TABLE]&quot;
                                     f&quot;WHERE [ID] = '{id}'&quot;)
          else:
              return {&quot;message&quot;: &quot;Missing required query param: id&quot;}, 400
  
          query_result = query_data.fetchall()
          return {&quot;data&quot;: query_result}
  </code></pre>
  <p>in App.Py</p>
  <pre><code>api.add_resource(Test, &quot;/test&quot;)
  </code></pre>