-
-
Save ryandotclair/404f2d4b7f05885d5b19 to your computer and use it in GitHub Desktop.
pg8000 connect
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
# Convert port to an int | |
db_port = int(db_port) | |
# Connect to the database | |
try: | |
db_connection = pg8000.connect(user=db_user, host=db_host,port=db_port,database=db_database,password=db_pass) | |
db_connection.autocommit = True | |
except Exception as e: | |
logger.critical( | |
'Unable to connect! Ensure $SRDBHOST, $SRDATABASE, $SRDBUSER and $SRDBPASS environmental variables are ' | |
'properly set\n{0}'.format(e)) | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment