def _test_connection(url):
        """Attempt to connect to postgres

        Args:
            url: string in the form "postgres://[user]:[password]@[host][:port][/database]"
        """
        import psycopg2
        try:
            with closing(psycopg2.connect(dsn=url)) as conn:
                conn.cursor()
        except psycopg2.OperationalError as e:
            raise ValidationError(e)
def _test_connection ( url ) : import psycopg2 try : with closing ( psycopg2 . connect ( dsn = url ) ) as conn : conn . cursor ( ) except psycopg2 . OperationalError as e : raise ValidationError ( e )
Attempt to connect to postgres

        Args:
            url: string in the form "postgres://[user]:[password]@[host][:port][/database]"