Пример #1
0
 def get_known_tables(self):
     dbserver = DbServerInfo(self, self.db_name)
     commands = dbserver.build_sql_command("'show tables'")
     echocmd = commands[0]
     mysqlcmd = commands[1]
     to_run = " ".join(echocmd) + " | " + " ".join(mysqlcmd) + " --silent"
     results = RunSimpleCommand.run_with_output(to_run, shell=True)
     return results.decode('utf-8').splitlines()
Пример #2
0
def run_simple_query(query, wiki):
    '''
    run a mysql query which returns only one field from
    one row.
    return the value of that one field (as a string)
    '''
    db_info = DbServerInfo(wiki, wiki.db_name)
    commands = db_info.build_sql_command(query)
    echocmd = commands[0]
    mysqlcmd = commands[1]
    to_run = " ".join(echocmd) + " | " + " ".join(mysqlcmd) + " --silent"
    log.info("running with no output: " + to_run)
    return RunSimpleCommand.run_with_output(to_run, shell=True)
Пример #3
0
    def get_command(self, wiki, outfile_path, outfile_base, base):
        '''
        given the output directory and filename and the wiki
        object, put together and return a command string
        for mysql to run the query and dump the output
        where required.
        '''
        if base is None:
            base = wiki

        dbserver = DbServerInfo(base, base.db_name)

        if outfile_base.endswith(".gz"):
            compress = "gzip"
        elif outfile_base.endswith(".bz2"):
            compress = "bzip2"
        else:
            compress = ""
        pipeto = "%s > %s" % (compress, outfile_path)

        query = self.query.format(w=wiki.db_name)
        return dbserver.build_sql_command(query, pipeto)