def __init__(self):
     if self.INSTANCE is not None:
         raise ValueError("An instantiation already exists!")
     else:
         db_config = read_db_config(filename='Config.ini', section='mysql')
         print(type(db_config), db_config)
         self.__cnxPool = MySQLConnectionPool(pool_name='myPool', pool_size=5, **db_config)
示例#2
0
def connect_use_config():
    db_config = read_db_config()

    try:
        print("Connecting to MySQL database.")
        conn = MySQLConnection(**db_config)

        if conn.is_connected():
            print("connection established")
            print(type(conn), conn)
        else:
            print("connection failed")
    except Error as error:
        print(error)
    finally:
        conn.close()
        print("Connection closed")
示例#3
0
def connect_use_config():
    db_config = read_db_config()

    try:
        print('Connecting to MySQL database...')
        conn = MySQLConnection(**db_config)  # 매개변수가 dictionary 자료구조

        if conn.is_connected():
            print('connection established.')
            print(type(conn), conn)
        else:
            print('connection failed.')

    except Error as error:
        print(error)

    finally:
        conn.close()
        print('Connection closed.')
示例#4
0
def read_config():
    print("\n== {}() ==".format(inspect.stack()[0][3]))
    db = read_db_config()
    print(type(db), " : ", db)