title: Select DateTime mysql query in python
body: <p>I have the following table in my MySQL database:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>id</th>
  <th>teplota</th>
  <th>created_at</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>12.521</td>
  <td>2017-02-01 17:49:53</td>
  </tr>
  <tr>
  <td>1</td>
  <td>12.852</td>
  <td>2017-02-02 17:50:53</td>
  </tr>
  <tr>
  <td>1</td>
  <td>12.852</td>
  <td>2017-02-03 17:50:53</td>
  </tr>
  <tr>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Column <code>created_at</code> has type timestamp, here is the column definition in my <code>CREATE TABLE</code> statement:</p>
  <pre class="lang-sql prettyprint-override"><code>created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  </code></pre>
  <p>When I use this select command in DB it normally works and I get correct output</p>
  <pre class="lang-sql prettyprint-override"><code>select * from ts2 where created_at &gt;= &quot;2017-02-01&quot; and created_at &lt; &quot;2017-02-02&quot;
  </code></pre>
  <p>But I have a problem if I want use it in my python code:</p>
  <pre class="lang-py prettyprint-override"><code>import datetime
  
  t1 = datetime.datetime(2017, 2, 1)
  t2 = datetime.datetime(2017, 2, 2)
  t1 = str(t1)
  t2 = str(t2)
  c.execute(&quot;select * from ts2 where created_at &gt;= %s and created_at &lt; %s;&quot; % (t1, t2)) 
  </code></pre>
  <p>I get the following error:</p>
  <blockquote>
  <p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '00:00:00 and created_at &lt; 2017-01-31 00:00:00' at line 1</p>
  </blockquote>
  <p>Any idea what I might be doing wrong?
  Thanks</p>