utils/RfamDB.py
def connect(db_config=None):
    """
    Connects to a specific database and returns a mysql connection object.
    :param db_config: database config values
    :type db_config: dict
    :return: db connection
    """
    db_config = db_conf if db_config is None else db_config
    cnx = None
    try:
        cnx = mysql.connector.connect(user=db_config["user"],
                                      password=db_config["pwd"],
                                      host=db_config["host"],
                                      database=db_config["db"],
                                      port=db_config["port"])

    except mysql.connector.Error as err:

        if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
            print("Wrong username or password")
            logging.debug("Wrong username or password: {0}".format(err))

        elif err.errno == errorcode.ER_BAD_DB_ERROR:
            print("Database does not exist")
            logging.debug("Database does not exist: {0}".format(err))

        else:
            print(err)
            logging.debug("MySQL error has occurred: {0}".format(err))

    return cnx

    Connects to a specific database and returns a mysql connection object.
    :param db_config: database config values
    :type db_config: dict
    :return: db connection
    
Connects to a specific database and returns a mysql connection object.
Connects to a specific database and returns a mysql connection object .
def connect(db_config=None):
    db_config = db_conf if db_config is None else db_config
    cnx = None
    try:
        cnx = mysql.connector.connect(user=db_config["user"],
                                      password=db_config["pwd"],
                                      host=db_config["host"],
                                      database=db_config["db"],
                                      port=db_config["port"])
    except mysql.connector.Error as err:
        if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
            print("Wrong username or password")
            logging.debug("Wrong username or password: {0}".format(err))
        elif err.errno == errorcode.ER_BAD_DB_ERROR:
            print("Database does not exist")
            logging.debug("Database does not exist: {0}".format(err))
        else:
            print(err)
            logging.debug("MySQL error has occurred: {0}".format(err))
    return cnx
def connect ( db_config = None ) : db_config = db_conf if db_config is None else db_config cnx = None try : cnx = mysql . connector . connect ( user = db_config [ "user" ] , password = db_config [ "pwd" ] , host = db_config [ "host" ] , database = db_config [ "db" ] , port = db_config [ "port" ] ) except mysql . connector . Error as err : if err . errno == errorcode . ER_ACCESS_DENIED_ERROR : print ( "Wrong username or password" ) logging . debug ( "Wrong username or password: {0}" . format ( err ) ) elif err . errno == errorcode . ER_BAD_DB_ERROR : print ( "Database does not exist" ) logging . debug ( "Database does not exist: {0}" . format ( err ) ) else : print ( err ) logging . debug ( "MySQL error has occurred: {0}" . format ( err ) ) return cnx
Connects to a specific database and returns a mysql connection object.
Connects to a specific database and returns a mysql connection object .
"""
    Connects to a specific database and returns a mysql connection object.
    :param db_config: database config values
    :type db_config: dict
    :return: db connection
    """
None
db_config
database config values
database config values