Sequelize Create Database

前端 未结 4 1133
耶瑟儿~
耶瑟儿~ 2021-02-05 01:42

Is there a way to have sequelize create the database I\'m trying to connect to if it doesn\'t exist?

I have a raw MySQL instance and I get this error back:



        
4条回答
  •  梦毁少年i
    2021-02-05 02:08

    In my case I was using sqlite, but the idea was the same. I needed to create the database first with sqlite3.

    const sqlite = require('sqlite3');
    const db = new sqlite.Database('/path/to/database.sqlite');
    const sequelize = new Sequelize('database', '', '', {
      dialect: 'sqlite',
      storage: '/path/to/database.sqlite',
      ...
    });
    

提交回复
热议问题