Postgres SSL SYSCALL error: EOF detected with python and psycopg

前端 未结 7 1911
误落风尘
误落风尘 2020-12-15 03:40

Using psycopg2 package with python 2.7 I keep getting the titled error: psycopg2.DatabaseError: SSL SYSCALL error: EOF detected

It only occurs when I add a WHE

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 03:53

    Very similar answer to what @FoxMulder900 did, except I could not get his first select to work. This works, though:

    WITH long_running AS (
        SELECT pid, now() - pg_stat_activity.query_start AS duration, query, state
        FROM pg_stat_activity
        WHERE (now() - pg_stat_activity.query_start) > interval '1 minutes'
          and state = 'active'
    )
    SELECT * from long_running;
    

    If you want to kill the processes from long_running just comment out the last line and insert SELECT pg_cancel_backend(long_running.pid) from long_running ;

提交回复
热议问题