Query on a MySQL DB

    0

    3

    Alex Martinez

    database

    The code connects to a database, and then queries it for information. If there are any errors, they are thrown. The resulting output will show the connected status and the results of the query.

    Shortcut: js.mysql.query

    con.connect(function(err) {
      if (err) throw err;
      console.log("Connected!");
      con.query(sql, function (err, result) {
        if (err) throw err;
        console.log("Result: " + result);
      });
    });
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.