Keeping postgres command prompt open after script runs

Hello, I have a simple script to connect to my postgres database in vscode, which it does successfully, but it immediately exits the postgres command prompt in the terminal and reverts back to the file directory command prompt. I’m wondering if there’s a way to keep that postgres command prompt open after my script runs. Here’s the script.

#=============== CONNECT TO DATABASE =================================================
#Credentials defined in config file
conn_string = 'host=' + PGHOST + " port=" + "5432" + " dbname=" + PGDATABASE + ' user=' + PGUSER + " password=" + PGPASS
conn = psycopg2.connect(conn_string)
print("Connected to Database!")

cursor = conn.cursor()

I’ve had someone explain to me the difference between psycopg2 and psql.

The former is used to query the database and interact with it within a script, while the latter would be for running queries from the command line.