sequelize.js how can I reconnect after close

Viewed 176

I use the sequelize.js to connect sqlite, but I must to close the connect because I want to modify the sqlite's file. Windows cannot modify the file when it's opening.

I create the object like this:

const sequelize = new Sequelize('database', null, null, {
    dialect: 'sqlite',
    storage: 'db.sql',
    define: {
      timestamps: false,
      freezeTableName: true
    },
    dialectModule: sqlite3
  })

And when I close the connect, I cannot reconnect sqlite by the original object. I try to use the ConnectionManager initPools, but it does not work.

sequelize.close()
// do something ...
sequelize.connectionManager.initPools()
sequelize.authenticate() // raise the error by disconnect
0 Answers
Related