Struggling to convert a mysql datetime object to a python string of a different format
nikos.the.gr33k at gmail.com
Thu Aug 5 23:01:28 CEST 2010
>On 5 Αύγ, 22:09, Tim Chase <python.l... at tim.thechases.com> wrote:
> On 08/05/10 13:52, Νίκος wrote:
> > dataset = cursor.fetchall()
> > for row in dataset:
> > print ( '''<tr> ''' )
As i have it the returned 'dataset' is stored line per line to 'row'.
'dataset' in here is a 'list of tuples' right?
'row' in here is a tuple form the above list of tuples right?
Am i understanding this correctly?!
> Well, depending on whether "row" is a tuple or a list, you can do
It was a tuple. But it migth as well be a list too?!?!
Could 'dataset' be a 'list of lists' as well?
How one would know in which way the returned mysql data is saved in?
> Though I think I'd make it a bit clearer by naming the fields:
> for host, hits, dt in dataset:
> print ("<tr>")
> for item in (host, hits, dt.strftime(...)):
> print ("<td>%s</td>" % item)
> print ("</tr>")
Cool! I myself like this solution best over the all working other!
very nice approach thank you very much! Is what i anted and couldn't
But please tell me if in my example 'row' was a tuple, what kind of
objects is 'host', 'hits', 'dt' here and how do they sore the data?
Thanks again for the cool examples!
More information about the Python-list