MariaDB connection with Sequelize(MariaDB 与 Sequelize 的连接)
问题描述
我一直在使用 Sequelize 检查 MariaDB 的连接性.
I have been checking for the connectivity of MariaDB, with Sequelize.
const Sequelize = require('sequelize');
// Setting up database (MariaDB) connection
const sequelize = new Sequelize('dbName', 'usr', 'pass', {
host: 'localhost',
dialect: 'mariadb'
});
但我收到以下错误:
/home/lt-196/api/node_modules/sequelize/lib/sequelize.js:236
throw new Error('The dialect ' + this.getDialect() + ' is not supported. Supported dialects: mssql, mysql, postgres, and sqlite.');
^
Error: The dialect mariadb is not supported. Supported dialects: mssql, mysql, postgres, and sqlite.
at new Sequelize (/home/lt-196/api/node_modules/sequelize/lib/sequelize.js:236:15)
at Object.<anonymous> (/home/lt-196/api/app.js:21:19)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
推荐答案
MariaDB为了兼容 MariaDB,您必须安装包 mariasql@0.1.20 或更高版本.配置需要如下所示:
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'
})
或者试试这个:
MariaSQL:https://www.npmjs.com/package/mariasql
一个 node.js 绑定到 MariaDB 的非阻塞(MySQL 兼容)客户端库.
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.
MariaSQL is recommended.
这篇关于MariaDB 与 Sequelize 的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MariaDB 与 Sequelize 的连接
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- SQL 临时表问题 2022-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01