Created
May 30, 2019 10:46
-
-
Save jgrocha/015f649ba00ddbec87d1026e95a75929 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psycopg2 | |
connection = psycopg2.connect(service='pg_trabalho') | |
# connection = psycopg2.connect(user = "cmb.user", password = "xxxxxxxx", host = "192.168.1.24", port = "5432", database = "trabalho") | |
cursor = connection.cursor() | |
# Print PostgreSQL Connection properties | |
print ( connection.get_dsn_parameters(),"\n") | |
# Print PostgreSQL version | |
cursor.execute("SELECT version();") | |
record = cursor.fetchone() | |
print("You are connected to - ", record,"\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment