MySQL validation

Learn how to validate MySQL using the CLI action step and SQL queries.

You can use the CLI action step to perform queries and run validations on MySQL database.

Example code:

const dbName = "XXXXX";
const userName = "XXXXX";
const password = "XXXXX";
const host = "XXXXX";
const port = XXXXX;

const sequelize = new Sequelize(dbName, userName, password, {
  dialect: "mysql",
  host,
  port
});

return sequelize
  .query("SELECT name FROM myTable where id = 1;", {
    plain: true,
    raw: true,
    type: Sequelize.QueryTypes.SELECT
  })
  .then(myTableRows => {
    const result = myTableRows && JSON.stringify(myTableRows);
    console.log("Query result", result);
    if (!myTableRows || myTableRows.name !== expectedValue) {
      return Promise.reject(new Error("Failed to find raw"));
    }
  });

Parameters - Packages and JavaScript used in this example:

1.name: Sequelize, type: Package, value: [email protected]
2.name: mysql2, type: Package, value: [email protected]
3.name: expectedValue, type: JavaScript, value: "fdssdf dfdf"

see screenshot:

224224