When I execute ordinary Select correct results are returned, but when I execute this select for DB uptime it returns same first result all the time. I did check Postgres logs and I see that select is executed.
#!/usr/bin/python3
import psycopg2
from time import sleep
conn = psycopg2.connect("dbname='MyDB' user='root' host='127.0.0.1' password='********'")
cur = conn.cursor()
def test():
e = 0
while e != 100:
cur.execute("SELECT date_trunc('second', current_timestamp - pg_postmaster_start_time()) as uptime;")
uptv = cur.fetchone()
print(uptv)
e += 1
sleep(0.1)
test()
autocommitoff?..