python 3.8.10
import psycopg2
conn = psycopg2.connect("dbname=dbname host=localhost user=user password=password")
cur = conn.cursor()
cur.execute("select * from test1")
print(cur.fetchone())
cur.close()
conn.close()
実行結果。タプルで返される。
('Hello World',)