TypeError: not enough arguments for format string - Python SQL connection while using %Y-%m
<pre><code>with engine.connect() as con:

    rs = con.execute("""
                        SELECT  datediff(STR_TO_DATE(CONCAT(year,'-',month,'-',day), '%Y-%m-%d') , current_date()) 
                        from TABLE 
                        WHERE datediff(STR_TO_DATE(CONCAT(year,'-',month,'-',day), '%Y-%m-%d') , current_date()) &lt; 900
                        group by STR_TO_DATE(CONCAT(year,'-',month,'-',day), '%Y-%m-%d');
                    """)
</code></pre>

<p>I feel the compiler is getting confused with '%Y-%m-%d', I might be wrong. Could someone help me on how to avoid this error:</p>

<blockquote>
  <p>Type Error:not enough arguments for format string</p>
</blockquote>

<p>You need to escape the <code>%</code>:</p>

<pre><code>with engine.connect() as con:

    rs = con.execute("""
                        SELECT  datediff(STR_TO_DATE(CONCAT(year,'-',month,'-',day), '%%Y-%%m-%%d') , current_date()) 
                        from TABLE 
                        WHERE datediff(STR_TO_DATE(CONCAT(year,'-',month,'-',day), '%%Y-%%m-%%d') , current_date()) &lt; 900
                        group by STR_TO_DATE(CONCAT(year,'-',month,'-',day), '%%Y-%%m-%%d');
                    """)
</code></pre>

<p><code>%</code> is a reserved character in MySQL (wildcard).</p>

python mysql compiler-errors python-3.5