title: Flask SQL-Alchemy query is returning null for data that exists in my database. What could be the cause
body: <p>My python program is meant to query my MySQL database for a record. The record exists in the database and contains data but the program returns null values. The table that gets queried is titled <strong>Market</strong>. In that table there is a column titled <strong>market_cap</strong> and a column titled <strong>volume</strong>. When I use MySQLWorkbench to query my database, the result shows that there is data in the columns. However, the program receives null.</p>
  
  <p>Attached are two images (links, because I need to earn 10 reputation points to embed images in a post):</p>
  
  <ol>
  <li><a href="https://i.stack.imgur.com/Oaou2.jpg" rel="nofollow noreferrer">MySql database column image</a><br>
  shows a view of the column in my database that is having issues.
  From the image, you can see that the data I need exists in my database.</li>
  <li><p><a href="https://i.stack.imgur.com/o5Ur7.jpg" rel="nofollow noreferrer">Code with results from Pycharm debugger</a><br>
  Before running the debugger, I set a breakpoint right after the line where
  the code queries the database for an object. Image two shows the output I
  received when the code queried the database.</p>
  
  <ol start="3">
  <li><p><a href="https://i.stack.imgur.com/4rdkc.jpg" rel="nofollow noreferrer">Screenshot of the Market Model</a></p></li>
  <li><p><a href="https://i.stack.imgur.com/lQhHc.jpg" rel="nofollow noreferrer">Screenshot of the solution</a> I found out that converting the market cap(market_cap) before adding it to the dictionary(price_map) returns the correct value. You can see it in line 138.  </p></li>
  </ol></li>
  </ol>
  
  <p>What could cause existent data in a record to be returned as null?</p>
  
  <pre><code>import logging
  from flask_restful import Resource
  from api.resources.util.date_util import pretty_date_to_epoch, 
  epoch_to_pretty_date
  from common.decorators import log_exception
  from db.models import db, Market
  log = logging.getLogger(__name__)
  
  
  def map_date_to_price():
      buy_date_list = ["2015-01-01", "2015-02-01", "2015-03-01"]
      sell_date_list = ["2014-12-19", "2014-01-10", "2015-01-20",
                        "2016-01-10"]
      date_list = buy_date_list + sell_date_list    
      market_list = []
      price_map = {}
      for day in date_list:
          market_list.append(db.session.query(Market).
          filter(Market.pretty_date == day).first())
      for market in market_list:
          price_map[market.pretty_date] = market.market_cap
  
      return price_map
  </code></pre>