Re: cannot insert a timestamp
Al Niessner <[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <1244653216.4273.3.camel@charon> |
I did have an extra set of quotes in there. Seems as though I wanted my time stamps in UTC (or GMT) and the only way to do that with V1 was to extract _o and then call gmtime() at which point I needed an extra set of quotes around. Turns out that is a problem with V2. Now I have to live with my timestamps being whatever zone the ticks are in. I care, but not enough. I will just live with local timezones. Thanks to everyone for their help. On Wed, 2009-06-10 at 11:09 +0800, James Henstridge wrote: > On Wed, Jun 10, 2009 at 7:34 AM, Al Niessner <[email protected]> wrote: > > > > self.__cursor.execute (command, value) > > > > Building up the command to match the dictionary 'value' is pretty > > complicated because it handles more than one table. However it is the > > usual building a string thing. Plus all the same code works with psycopg > > v1. To switch between them, I just change the import and yank the _o > > from the timestamp. No other changes are required. > > I don't see these problems locally. Are you adding extra quotes in > your query by any chance? > > >>> import psycopg2 > >>> conn = psycopg2.connect(database='template1') > >>> cursor = conn.cursor() > >>> cursor.execute("SELECT %s", (psycopg2.TimestampFromTicks(42),)) > >>> cursor.fetchone() > ('1970-01-01T08:00:42+08:00',) > > James. -- Al Niessner I have never found the companion that was so companionable as solitude. - From Walden by Henry David Thoreau The universe is indifferent, and life is brutal; however, it is man's choice of behavior that makes them malevolent rather than benevolent. Some will fall in love with life and drink it from a fountain That is pouring like an avalanche coming down the mountain. - From the song Pepper by the Butthole Surfers