title: How to compare a Python float with a Mysql decimal in python?
body: <p>I'm storing price as decimal(8,2) in mysql and I need to compare equality with a float in python.</p>
  
  <p>Say I have <code>4.28</code> in database and <code>select</code> returns <code>price = (Decimal(4.28),)</code>. I convert it to python decimal by <code>decimal.Decimal(price[0])</code>, but <code>decimal.Decimal(price[0]) == 4.28</code> returns false.</p>
  
  <p>Is there a way to compare equality directly other than comparing the difference with a small number, i.e.
  <code>decimal.Decimal(price[0]) - decimal.Decimal(4.28) &lt; 0.01</code></p>
  
  <p>Thanks</p>