pip install psycopg2-binary
import psycopg2
conn = psycopg2.connect(dsn='postgresql://user:pass@localhost/mydb')
cur = conn.cursor()
cur.execute('SELECT * FROM users WHERE age > %s', (25,))
rows = cur.fetchall()
conn.commit()
cur.close()
conn.close()