title: SqlAlchemy: cast to int if possible/test if string is numeric
body: <p>I have a TEXT column with a lot of various values, some numeric, some not. I want to find all rows containing a numeric value greater than a given number.</p>
  
  <p>I can use <code>cast</code>:</p>
  
  <pre class="lang-py prettyprint-override"><code>def findAttrValAbove42():
      q = db.query(AttrVal)
      q = q.filter(cast(AttrVal.value, Numeric) &gt; 42)
      return list(q)
  </code></pre>
  
  <p>The problem is when <code>cast</code> encounters a row with a value like "cookies", it throws an error. So, I need a way to either have <code>cast</code> return a default value on failure, or additionally filter for only numeric values, eg:</p>
  
  <pre class="lang-py prettyprint-override"><code>def findAttrValAbove42():
      q = db.query(AttrVal)
      q = q.filter(AttrVal.value.isNumeric())
      q = q.filter(cast(AttrVal.value, Numeric) &gt; 42)
      return list(q)
  </code></pre>
  
  <p>But I can't find any "is numeric" or "match regular expression" function that could do that filtering.</p>