Example #1
0
    def _load_mysql_dump_file(self, engine, file_name):
        for key, eng in self.engines.items():
            if eng is engine:
                conn_string = self.test_databases[key]
                conn_pieces = urlparse.urlparse(conn_string)
                if conn_string.startswith('mysql'):
                    break
                else:
                    return

        (user, password, database, host) = \
            test_migrations.get_db_connection_info(conn_pieces)
        cmd = ('mysql -u \"%(user)s\" -p\"%(password)s\" -h %(host)s %(db)s '
               ) % {'user': user, 'password': password,
                    'host': host, 'db': database}
        file_path = os.path.join(os.path.dirname(__file__),
                                 file_name)
        with open(file_path) as sql_file:
            process = subprocess.Popen(cmd, shell=True,
                                       stdout=subprocess.PIPE,
                                       stdin=sql_file,
                                       stderr=subprocess.STDOUT)
            output = process.communicate()[0]
            self.assertEqual(0, process.returncode,
                             "Failed to run: %s\n%s" % (cmd, output))
Example #2
0
    def _load_mysql_dump_file(self, engine, file_name):
        for key, eng in self.engines.items():
            if eng is engine:
                conn_string = self.test_databases[key]
                conn_pieces = urlparse.urlparse(conn_string)
                if conn_string.startswith('mysql'):
                    break
                else:
                    return

        (user, password, database, host) = \
            test_migrations.get_db_connection_info(conn_pieces)
        cmd = ('mysql -u \"%(user)s\" -p\"%(password)s\" -h %(host)s %(db)s '
               ) % {'user': user, 'password': password,
                    'host': host, 'db': database}
        file_path = os.path.join(os.path.dirname(__file__),
                                 file_name)
        with open(file_path) as sql_file:
            process = subprocess.Popen(cmd, shell=True,
                                       stdout=subprocess.PIPE,
                                       stdin=sql_file,
                                       stderr=subprocess.STDOUT)
            output = process.communicate()[0]
            self.assertEqual(0, process.returncode,
                             "Failed to run: %s\n%s" % (cmd, output))