Skip to content

Instantly share code, notes, and snippets.

@jgrocha
Created May 30, 2019
Embed
What would you like to do?
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