timestamp and mxDateTime

Michael Hipp <[email protected]> Tue, 28 Sep 2004 09:15:54 -0500
Newsgroups gmane.comp.python.db.pypgsql.user
Message-ID <[email protected]>
Hello, first post.

I'm fairly new to Python, PostgreSQL and pyPgSQL so please forgive if 
I'm doing something dumb ...

How do you store an mxDateTime in a database? Here's the essence of my code:

--------------------------
from   pyPgSQL import PgSQL
from   mx.DateTime import *

db = PgSQL.connect(dsn="localhost", database="test")
cursor = db.cursor()

rightnow = now()
cursor.execute("insert into dailylog values (%s)", rightnow)
--------------------------

That column in PostgreSQL was defined as a 'timestamp' type.

This gives error:
libpq.OperationalError: ERROR:  value too long for type character varying(4)

Any help appreciated,
Michael


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php