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? 3 2432
In article <bew5f.2828$UF4.1651@fed1read02>,
"Sean Berry" <se**@buildingonline.com> 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?
Two suggestions:
1. Read up on strftime.
2. Rethink what you're doing because it's almost certainly wrong.
rg
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 md*@micah.elliott.name
" " """
On Wed, 19 Oct 2005 11:27:24 -0700, "Sean Berry"
<se**@buildingonline.com> declaimed the following in comp.lang.python: 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
Do you? But, when I retrieve the value and print it I get 2005-10-19 11:16:17
And that IS the format MySQL returns timestamp fields in its own
clients. UNLESS you perform an arithmetic operation on the field...
SELECT t.id, t.atime, t.aTime + 0 FROM times t
id atime t.aTime + 0
1 2005-10-19 23:04:40 20051019230440
2 2005-10-19 23:04:44 20051019230444
3 2005-10-19 23:04:44 20051019230444
4 2005-10-19 23:05:58 20051019230558
-- ================================================== ============ < wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < wu******@dm.net | Bestiaria Support Staff < ================================================== ============ < Home Page: <http://www.dm.net/~wulfraed/> < Overflow Page: <http://wlfraed.home.netcom.com/> < This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dave Harrison |
last post by:
Hi all, got a problem combinging mx and MySQLdb, when I build and install both for my Python2.1 install on a Solaris 9 box I can import mx fine, but importing MySQLdb causing python to core dump.
...
|
by: Peter Nikolaidis |
last post by:
Greetings,
I am attempting to get MySQLdb 0.9.2 installed on Mac OS 10.2 with a
Fink distribution of Python 2.2.2. I have seen only a few posts on the
subject, some of them relate to...
|
by: Derek Fountain |
last post by:
I was trying to use MySQLdb to connect to a database. All is OK, except I
can't figure out how to get the details of an error. Suppose I try to
connect to a non existant server, or with the wrong...
|
by: Brian Kelley |
last post by:
I am trying to use threads and mysqldb to retrieve data from multiple
asynchronous queries.
My basic strategy is as follows, create two cursors, attach them to the
appropriate databases and then...
|
by: Tim Williams |
last post by:
I'm trying to write a simple python program to access a MySQL
database. I'm having a problem with using MySQLdb to get the results
of a SQL command in a cursor. Sometimes the cursor.execute works,...
|
by: Steve |
last post by:
Darwin steve.local 8.3.0 Darwin Kernel Version 8.3.0: Mon Oct 3
20:04:04 PDT 2005; root:xnu-792.6.22.obj~2/RELEASE_PPC Power Macintosh
powerpc
MacOSX 10.4.3
mysql Ver 14.7 Distrib 4.1.14, for...
|
by: Yi Xing |
last post by:
Hi,
I met the following error when I tried to install MySQLdb. I had no
problem installing numarray, Numeric, Rpy, etc. Does anyone know
what's the problem? Thanks!
running install
running...
|
by: Steve Holden |
last post by:
Vaibhav.bhawsar wrote:
imported
The point here is that MySQLdb is a package, not a module. Some packages
have their top-level __init__.py import the package's sub-modules or
sub-packages to...
|
by: Edwin.Madari |
last post by:
replace the name of table before calling *.execute.
s.dbptr.execute(str % (e))
good luck.
Edwin
-----Original Message-----
From: python-list-bounces+edwin.madari=verizonwireless.com@python.org...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |