On Thu, Aug 01, 2013 at 01:25:53PM +0000, Christian.Strobl@dlr.de wrote:
> thanks a lot, i see now. i get a python datetime object, not a result string. i was to fixed to my database way of
thinking
>
> with
>
> In [6]: rows[0][0].isoformat()
> Out[6]: '2013-07-29T09:02:00+00:00'
>
> i get what i want.
>
> an additional question: for more complex queries it is a
> little bit time consuming to change all queries with
> mogrify. do you know if it is possible to send raw sql to
> the database
No need for mogrify ??
query = "SELECT ...;"
conn = psycopg2.connection(...)
curs = conn.cursor()
curs.execute(query)
results = curs.fetch*()
Maybe you want to read the documentation ?
> and to get only the output from the database
> back without any kind of python object creation.
You could cast every SELECTed column to TEXT as
has been suggested already but why ? You could also
just <'%s' % object> it in Python, or some such measure.
Karsten
--
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346