API Reference Source
Docs v5

Dialects

Sequelize is independent from specific dialects. This means that you'll have to install the respective connector library to your project yourself.

MySQL

In order to get Sequelize working nicely together with MySQL, you'll need to install[email protected]^1.5.2or higher. Once that's done you can use it like this:

const sequelize = new Sequelize('database', 'username', 'password', {
  dialect: 'mysql'
})

Note: You can pass options directly to dialect library by setting the dialectOptions parameter.

MariaDB

Library for MariaDB is mariadb.

const sequelize = new Sequelize('database', 'username', 'password', {
  dialect: 'mariadb',
  dialectOptions: {connectTimeout: 1000} // mariadb connector option
})

or using connection String:

const sequelize = new Sequelize('mariadb://user:[email protected]:9821/database')

SQLite

For SQLite compatibility you'll need[email protected]^4.0.0. Configure Sequelize like this:

const sequelize = new Sequelize('database', 'username', 'password', {
  // sqlite! now!
  dialect: 'sqlite',

  // the storage engine for sqlite
  // - default ':memory:'
  storage: 'path/to/database.sqlite'
})

Or you can use a connection string as well with a path:

const sequelize = new Sequelize('sqlite:/home/abs/path/dbname.db')
const sequelize = new Sequelize('sqlite:relativePath/dbname.db')

PostgreSQL

For PostgreSQL, two libraries are needed, [email protected]^7.0.0 and pg-hstore. You'll just need to define the dialect:

const sequelize = new Sequelize('database', 'username', 'password', {
  // gimme postgres, please!
  dialect: 'postgres'
})

To connect over a unix domain socket, specify the path to the socket directory in the host option.

The socket path must start with /.

const sequelize = new Sequelize('database', 'username', 'password', {
  // gimme postgres, please!
  dialect: 'postgres',
  host: '/path/to/socket_directory'
})

MSSQL

The library for MSSQL is[email protected]^6.0.0 You'll just need to define the dialect. Please note: [email protected]^6.0.0 requires you to nest MSSQL specific options inside an additional options-object inside the dialectOptions-object.

const sequelize = new Sequelize('database', 'username', 'password', {
  dialect: 'mssql',
  dialectOptions: {
    options: {
      useUTC: false,
      dateFirst: 1,
    }
  }
})