MariaDB connection with Sequelize

前端 未结 2 765
旧时难觅i
旧时难觅i 2021-01-22 19:44

I have been checking for the connectivity of MariaDB, with Sequelize.

const Sequelize = require(\'sequelize\');

// Setting up database (MariaDB) connection
cons         


        
2条回答
  •  猫巷女王i
    2021-01-22 20:10

    https://github.com/MariaDB/mariadb-connector-nodejs

    NPM

        npm install --save mariadb
        npm install --save sequelize@next
    

    Yarn

        yarn add mariadb
        yarn add sequelize@next
    
      const Sequelize = require('sequelize'),
        sequelize = new Sequelize(process.env.db_name, process.env.db_user, process.env.db_pass, {
        dialect: 'mariadb',
        dialectOptions: {
          socketPath: process.env.db_socket,
          timezone: process.env.db_timezone
        },
        pool: {
          min: 0,
          max: 5,
          idle: 10000
        },
        define: {
          charset: 'utf8',
          timestamps: false
        },
        benchmark: false,
        logging: false
      })
    

提交回复
热议问题