■ Connection 클래스의 get_dsn_parameters 메소드를 사용해 DSN 매개 변수를 구하는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import psycopg2 connection = psycopg2.connect(host = "192.168.29.118", port = "5432", database = "testdb", user = "testuser1", password = "test1234") cursor = connection.cursor() print("=" * 100) print(connection.get_dsn_parameters()) print("=" * 100) print() cursor.close() connection.close() """ ==================================================================================================== {'user': 'testuser1', 'channel_binding': 'prefer', 'dbname': 'testdb', 'host': '192.168.29.118', 'port': '5432', 'options': '', 'sslmode': 'prefer', 'sslcompression': '0', 'sslcertmode': 'allow', 'sslsni': '1', 'ssl_min_protocol_version': 'TLSv1.2', 'gssencmode': 'prefer', 'krbsrvname': 'postgres', 'gssdelegation': '0', 'target_session_attrs': 'any', 'load_balance_hosts': 'disable'} ==================================================================================================== """ |
▶ requirements.txt
1 2 3 |
psycopg2-binary==2.9.9 |