Re: [(datetime.datetime(2013, 7, 29, 9, 2, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=0, name=None)),)]

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: psycopg(at)postgresql(dot)org
Subject: Re: [(datetime.datetime(2013, 7, 29, 9, 2, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=0, name=None)),)]
Date: 2013-08-01 13:31:36
Message-ID: 20130801133136.GA18910@hermes.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Thu, Aug 01, 2013 at 01:25:53PM +0000, Christian(dot)Strobl(at)dlr(dot)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

In response to

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2013-08-01 13:44:43 Re: Fw: Problem with psycopg2, bytea, and memoryview
Previous Message Christian.Strobl 2013-08-01 13:25:53 Re: [(datetime.datetime(2013, 7, 29, 9, 2, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=0, name=None)),)]