title: What's the best way to store a python timedelta value in mysql?
body: <p>I need to store an uptime in a mysql environment.
  The uptime can vary from a few hours to more than one year. I was considering using a DATETIME type for mysql.
  I'm working with python, and the uptime is obtained from </p>
  
  <pre class="lang-python prettyprint-override"><code>def convertdate(lastrestart):
     # now in datetime
     nowdt=datetime.now()
  
     # last_restarted in datetime
     lastrestarted_dt=datetime.strptime(lastrestart, "%Y-%m-%d %H:%M:%S")
  
     # timedelta in datetime! 
     uptimeInDT=nowdt-lastrestarted_dt
  
     #timedelta in seconds
     secondsUptime=uptimeInDT.seconds
  
     # string conversion wont work so much for a datetime field.
     print str(uptimeInDT)
  </code></pre>
  
  <p>Is this the best way for doing this job? Sould I use other solutions? 
  SEC_TO_TIME() in mysql has a smaller range and wont work, and there's no function from sec to datetime.
  Maybe I should save the seconds and get used to that.
  Thanks</p>