Skip to content Skip to sidebar Skip to footer

MariaDB Connection With Sequelize

I have been checking for the connectivity of MariaDB, with Sequelize. const Sequelize = require('sequelize'); // Setting up database (MariaDB) connection const sequelize = new Seq

Solution 1:

MariaDB For MariaDB compatibility you have to install the package mariasql@0.1.20, or higher. The configuration needs to look like this:

var sequelize = new Sequelize('database', 'username', 'password', {
  dialect: 'mariadb'
})

Or Try this:

MariaSQL: https://www.npmjs.com/package/mariasql

A node.js binding to MariaDB's non-blocking (MySQL-compatible) client library.

var Client = require('mariasql');

var c = new Client({
  host: '127.0.0.1',
  user: 'foo',
  password: 'bar'
});

c.query('SHOW DATABASES', function(err, rows) {
  if (err)
    throw err;
  console.dir(rows);
});

c.end();

MariaSQL is recommended.


Solution 2:

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
  })

Post a Comment for "MariaDB Connection With Sequelize"