How to prevent Sequelize from outputting SQL to the console on execution of query?

How to prevent Sequelize from outputting SQL to the console on execution of query?

Asked on October 24, 2018 in node.js.
Add Comment


  • 3 Answer(s)

    We create our Sequelize object, pass false to the logging parameter:

    var sequelize = new Sequelize('database', 'username', 'password', {
     
        // disable logging; default: console.log
        logging: false
    });
    

    the above code can be used to prevent Sequelize from outputting SQL to the console on execution of query

    Answered on October 24, 2018.
    Add Comment

    If ‘config/config.json’ file is used then add ‘logging’: false to the config.json

    // file config/config.json
    {
        {
        "development": {
            "username": "username",
            "password": "password",
            "database": "db_name",
            "host": "127.0.0.1",
            "dialect": "mysql",
            "logging": false
         },
            "test": {
        ...
    }
    
    Answered on October 24, 2018.
    Add Comment

    You can use config.json :

    {
        "development": {
            "username": "root",
            "password": null,
            "logging" : false,
            "database": "posts_db_dev",
            "host": "127.0.0.1",
            "dialect": "mysql",
            "operatorsAliases": false
        }
    }
    
    Answered on October 24, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.