예제 #1
0
def get_datadir(reset_cache=False):
    """Return the data directory currently used by Mysql."""
    global DATADIR
    if not reset_cache and DATADIR:
        return DATADIR

    mycnf_contents = read_mycnf()

    # look for datadir parameter in my.cnf
    mycnf = dict(configurations.MySQLConfParser(mycnf_contents).parse())
    DATADIR = mycnf['datadir']

    return DATADIR
예제 #2
0
 def test_parse_my_cnf_correctly(self):
     config = """
     [mysqld]
     pid-file = /var/run/mysqld/mysqld.pid
     connect_timeout = 15
     # we need to test no value params
     skip-external-locking
     ;another comment
     !includedir /etc/mysql/conf.d/
     """
     cfg_parser = configurations.MySQLConfParser(config)
     parsed = cfg_parser.parse()
     d_parsed = dict(parsed)
     self.assertIsNotNone(d_parsed)
     self.assertEqual("/var/run/mysqld/mysqld.pid", d_parsed["pid-file"])
     self.assertEqual('15', d_parsed["connect_timeout"])
     self.assertEqual('1', d_parsed["skip-external-locking"])