示例#1
0
def con(host, port, auth_mech, tmp_db):
    # create the temporary database
    con = connect(host=host, port=port, auth_mechanism=auth_mech)
    cur = con.cursor()
    cur.execute('CREATE DATABASE {0}'.format(tmp_db))
    cur.close()
    con.close()

    # create the actual fixture
    con = connect(host=host,
                  port=port,
                  auth_mechanism=auth_mech,
                  database=tmp_db)
    yield con
    con.close()

    # cleanup the temporary database
    con = connect(host=host, port=port, auth_mechanism=auth_mech)
    cur = con.cursor()
    if hive:
        force_drop_hive_database(cur, tmp_db)
    else:
        force_drop_impala_database(cur, tmp_db)
    cur.close()
    con.close()
 def tearDownClass(cls):
     con = cls.driver.connect(host=ENV.host, port=ENV.port,
                              auth_mechanism=ENV.auth_mech)
     cur = con.cursor()
     if hive:
         force_drop_hive_database(cur, tmp_db)
     else:
         force_drop_impala_database(cur, tmp_db)
     cur.close()
     con.close()