[Zope-DB] Python/DCOracle Newbie seeking help
Matthew T. Kromer
matt at zope.com
Mon Aug 11 14:16:43 EDT 2003
If you do an int() of an OracleDate, it will convert into a
seconds-since-the-epoch format.
You can use that lke you would a time.time() number.
Sorisio, Chris wrote:
>Hola folks,
>
>I've just started playing with Python and DCOracle2, worked through some of
>the examples, pulled out data, etc. All's been well except for something
>that is driving me nuts.
>
>Example code:
>
>
>--snip--
>cdb.execute("select ps_idno, ps_dten, ps_stdt, ps_r1_us, ps_s1_us, ps_r2_us,
>nm_ltnm, mcmp.bs_name, mjobo.jc_idch from mnme, mpsn, mcmp, mjobo where
>ps_dten > '01-AUG-2003' and mcmp.bs_idno=mpsn.ps_cs_bs and
>mjobo.jc_idno=mpsn.ps_jc_jc and mnme.nm_idno=mpsn.ps_cn_nm")
>
>results = cdb.fetchall()
>
>for elements in results:
> exampledate = elements[2]
>
> print exampledate
> print `exampledate`
> testTime = time.strptime(y, "%Y-%m-%d %H:%M:%S")
> time = time.strftime("%d-%b-%Y", testTime)
> print time
>--snip--
>
>print exampledate returns a string of the format YYYY-MM-DD HH:MM:SS.
>print `exampledate` returns OracleDate("YYYY-MM-DD HH:MM:SS").
>
>Okay, that's fine, all understood, except:
>
>time.strptime complains that y is of type OracleDate and not a string. How
>do I convert it into a string?
>
>Thanks, I'm sure the answer will prompt me to wear a brown bag on my head
>for awhile.
>
>
>_______________________________________________
>Zope-DB mailing list
>Zope-DB at zope.org
>http://mail.zope.org/mailman/listinfo/zope-db
>
>
--
Matt Kromer
Zope Corporation http://www.zope.com/
More information about the Zope-DB
mailing list