Fetch time from mysql using python
Question: I am using the code below to fetch time entity called `fajr_begins` from
`mysql`. I am able to print `fajr_begins` which is in the format: 5:27:00, how
can i convert this to a time format in python, so that i can manipulate the
time and add 15mins?

    
    
    cnx = mysql.connector.connect(host=mysql_remote_host, user=mysql_remote_host_user, password=mysql_remote_host_password, database=mysql_remote_host_database)
    cursor = cnx.cursor()
    cursor.execute("select * from prayertimes where DATE(date) = DATE(NOW())" )
    results = cursor.fetchall()
    id, date, fajr_begins, fajr_jamaat, sunrise, zuhr_begins, zuhr_jamaat, asr_begins, asr_jamaat, maghrib_jamaat, isha_begins, isha_jamaat = results[0]
    cursor.close()
    print fajr_begins
    


Answer: You have to convert it using
[`strptime`](https://docs.python.org/2/library/datetime.html#datetime.datetime.strptime).
`timedelta` will be use for adding minutes.

    
    
    >>> from datetime import datetime, timedelta
    >>> a = "05:27:00"
    >>> b = datetime.strptime(a, "%H:%M:%S")
    >>> print b
    1900-01-01 05:27:00
    >>> c = timedelta(minutes=15)
    >>> print c
    0:15:00
    >>> print b+c
    1900-01-01 05:42:00
    

