raf schrieb:
however, select now() returns the time at the start of the
transaction, not the time at the start of the connection
as you are seeing. that probably means that you are using
an old version of pygresql that keeps a transaction open
all the time. upgrading to pygresql-4 will solve your
problem unless you really have long running transactions
and need to know the time at various points inside it. if that's the case, then you need to select timeofday().

That's correct. But even with the current PyGres version (which Julio obviously has installed), now() gives the same date unless you explicitly issue a commit(), because it's still the same transaction. The following example demonstrates this:

db = pgdb.connect(database="test")

for i in range(6):
    if i > 2:
        db.commit()
    cur = db.cursor()
    cur.execute("select now(), clock_timestamp()")
    print i, cur.fetchone()
    sleep(1)

Note that this is not a bug, but the expected behavior. Usually, you set "last changed" columns with now(), and you want all such columns to be set to the same value in one transaction.

By the way, if you need the current time independent from the database, you can use datetime.now() from Python.

-- Christoph
_______________________________________________
PyGreSQL mailing list
[email protected]
http://mailman.vex.net/mailman/listinfo/pygresql

Reply via email to