Exemplo n.º 1
0
def get_dbapi_compliant_module(driver, prefered_drivers = None, quiet = False,
                               pywrap = False):
    """returns a fully dbapi compliant module"""
    try:
        mod = ADAPTER_DIRECTORY.adapt(driver, prefered_drivers, pywrap=pywrap)
    except NoAdapterFound as err:
        if not quiet:
            msg = 'No Adapter found for %s, returning native module'
            print(msg % err.objname, file=sys.stderr)
        mod = err.adapted_obj
    from clonedigger.logilab.common.adbh import get_adv_func_helper
    mod.adv_func_helper = get_adv_func_helper(driver)
    return mod
Exemplo n.º 2
0
def get_dbapi_compliant_module(driver,
                               prefered_drivers=None,
                               quiet=False,
                               pywrap=False):
    """returns a fully dbapi compliant module"""
    try:
        mod = ADAPTER_DIRECTORY.adapt(driver, prefered_drivers, pywrap=pywrap)
    except NoAdapterFound as err:
        if not quiet:
            msg = 'No Adapter found for %s, returning native module'
            print(msg % err.objname, file=sys.stderr)
        mod = err.adapted_obj
    from clonedigger.logilab.common.adbh import get_adv_func_helper
    mod.adv_func_helper = get_adv_func_helper(driver)
    return mod
Exemplo n.º 3
0

def get_dbapi_compliant_module(driver,
                               prefered_drivers=None,
                               quiet=False,
                               pywrap=False):
    """returns a fully dbapi compliant module"""
    try:
        mod = ADAPTER_DIRECTORY.adapt(driver, prefered_drivers, pywrap=pywrap)
    except NoAdapterFound, err:
        if not quiet:
            msg = 'No Adapter found for %s, returning native module'
            print >> sys.stderr, msg % err.objname
        mod = err.adapted_obj
    from clonedigger.logilab.common.adbh import get_adv_func_helper
    mod.adv_func_helper = get_adv_func_helper(driver)
    return mod


def get_connection(driver='postgres',
                   host='',
                   database='',
                   user='',
                   password='',
                   port='',
                   quiet=False,
                   drivers=PREFERED_DRIVERS,
                   pywrap=False):
    """return a db connexion according to given arguments"""
    module, modname = _import_driver_module(driver, drivers, ['connect'])
    try:
Exemplo n.º 4
0
    except ValueError:
        raise UnknownDriver('Unknown module %s for %s' % (module, database))
    modules.insert(0, module)
    
def get_dbapi_compliant_module(driver, prefered_drivers = None, quiet = False,
                               pywrap = False):
    """returns a fully dbapi compliant module"""
    try:
        mod = ADAPTER_DIRECTORY.adapt(driver, prefered_drivers, pywrap=pywrap)
    except NoAdapterFound, err:
        if not quiet:
            msg = 'No Adapter found for %s, returning native module'
            print >> sys.stderr, msg % err.objname
        mod = err.adapted_obj
    from clonedigger.logilab.common.adbh import get_adv_func_helper
    mod.adv_func_helper = get_adv_func_helper(driver)
    return mod

def get_connection(driver='postgres', host='', database='', user='', 
                  password='', port='', quiet=False, drivers=PREFERED_DRIVERS,
                  pywrap=False):
    """return a db connexion according to given arguments"""
    module, modname = _import_driver_module(driver, drivers, ['connect'])
    try:
        adapter = ADAPTER_DIRECTORY.get_adapter(driver, modname)
    except NoAdapterFound, err:
        if not quiet:
            msg = 'No Adapter found for %s, using default one' % err.objname
            print >> sys.stderr, msg
        adapted_module = DBAPIAdapter(module, pywrap)
    else: