Is it required to close a Psycopg2 connection at the end of a script?
问题 What are the consequences of not closing a psycopg2 connection at the end of a Python script? For example, consider the following snippet: import psycopg2 psycopg2.connect("dbname=test") The script opens a connection, but does not close it at the end. Is the connection still open at the end of the execution? If so, is there an issue with not closing the connection? 回答1: Normally when your python program exits, all the sockets it owns will be closed, and open transactions aborts. But it's good