question about timestamp and MySQLdb
Micah Elliott
mde at micah.elliott.name
Wed Oct 19 15:22:24 EDT 2005
On Oct 19, Sean Berry wrote:
> I am using MySQLdb to connect to a database and retrieve a timestamp
> from a table. The problem is I want the timestamp as a long,
> unformatted and all.
>
> In the table I have a timestamp like this
> 20051019111617
>
> But, when I retrieve the value and print it I get
> 2005-10-19 11:16:17
>
> I want the numeric version, not the converted date. Any suggestions?
Without giving any thought to MySQLdb or datetime, the simplest thing
that comes to mind is
>>> import re
>>> re.sub('( |-|:)', '', ' 2005-10-19 11:16:17')
'20051019111617'
--
_ _ ___
|V|icah |- lliott http://micah.elliott.name mde at micah.elliott.name
" " """
More information about the Python-list
mailing list