# Path: hgvs/exceptions.py
# class HGVSError(Exception):
#     pass
# 
# class HGVSDataNotAvailableError(HGVSError):
#     pass


import os
import re
import six
import hgvs
import logging
import inspect
import psycopg2
import psycopg2.extras
import psycopg2.pool
import contextlib
from six.moves.urllib import parse as urlparse
from hgvs.exceptions import HGVSError, HGVSDataNotAvailableError
        if self.application_name is None:
            st = inspect.stack()
            self.application_name = os.path.basename(st[-1][1])
        conn_args = dict(
            host=self.url.hostname,
            port=self.url.port,
            database=self.url.database,
            user=self.url.username,
            password=self.url.password,
            application_name=self.application_name + "/" + hgvs.__version__,
        )
        if self.pooling:
            _logger.info("Using UTA ThreadedConnectionPool")
            self._pool = psycopg2.pool.ThreadedConnectionPool(
                hgvs.global_config.uta.pool_min, hgvs.global_config.uta.pool_max, **conn_args)
        else:
            self._conn = psycopg2.connect(**conn_args)
            self._conn.autocommit = True

        self._ensure_schema_exists()

        # remap sqlite's ? placeholders to psycopg2's %s
        self._queries = {k: v.replace('?', '%s') for k, v in six.iteritems(self._queries)}

    def _ensure_schema_exists(self):
        # N.B. On AWS RDS, information_schema.schemata always returns zero rows
        r = self._fetchone("select exists(SELECT 1 FROM pg_namespace WHERE nspname = %s)",
                           [self.url.schema])
        if r[0]:
            return

# Path: hgvs/exceptions.py
# class HGVSError(Exception):
#     pass
# 
# class HGVSDataNotAvailableError(HGVSError):
#     pass


# Path: hgvs/dataproviders/ncbi.py
import os
import re
import six
import hgvs
import logging
import inspect
import psycopg2
import psycopg2.extras
import psycopg2.pool
import contextlib
from six.moves.urllib import parse as urlparse
from hgvs.exceptions import HGVSError, HGVSDataNotAvailableError

        if self.application_name is None:
            st = inspect.stack()
            self.application_name = os.path.basename(st[-1][1])
        conn_args = dict(
            host=self.url.hostname,
            port=self.url.port,
            database=self.url.database,
            user=self.url.username,
            password=self.url.password,
            application_name=self.application_name + "/" + hgvs.__version__,
        )
        if self.pooling:
            _logger.info("Using UTA ThreadedConnectionPool")
            self._pool = psycopg2.pool.ThreadedConnectionPool(
                hgvs.global_config.uta.pool_min, hgvs.global_config.uta.pool_max, **conn_args)
        else:
            self._conn = psycopg2.connect(**conn_args)
            self._conn.autocommit = True

        self._ensure_schema_exists()

        # remap sqlite's ? placeholders to psycopg2's %s
        self._queries = {k: v.replace('?', '%s') for k, v in six.iteritems(self._queries)}

    def _ensure_schema_exists(self):
        # N.B. On AWS RDS, information_schema.schemata always returns zero rows
        r = self._fetchone("select exists(SELECT 1 FROM pg_namespace WHERE nspname = %s)",
                           [self.url.schema])
        if r[0]:
            return

        raise HGVSDataNotAvailableError("specified schema ({}) does not exist (url={})".format(