connection
import psycopg2 from psycopg2 import Error, connection, cursor conn: connection | None = None c1: cursor | None = None try: conn = psycopg2.connect(host='localhost', port=5432, user='postgres', password='postgres', database='entail') c1 = conn.cursor() print(conn.get_dsn_parameters()) c1.execute('select version()') print(c1.fetchall()) except (Exception, Error) as e: print(e) finally: if connection and not connection.closed: if not c1.closed: c1.close() conn.close()
create table
标签:None,PostgreSQL,Python,psycopg2,cursor,connection,c1,conn From: https://www.cnblogs.com/dissipate/p/17364543.html