Skip to content

Instantly share code, notes, and snippets.

@jgrocha
Created May 30, 2019 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgrocha/015f649ba00ddbec87d1026e95a75929 to your computer and use it in GitHub Desktop.
Save jgrocha/015f649ba00ddbec87d1026e95a75929 to your computer and use it in GitHub Desktop.
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