const Sequelize = require('sequelize');
const sequelize = new Sequelize('mysql://root:password'+MysqlInfo.DatabaseURL+'mydb');
sequelize.authenticate()
.then(() => {
console.log('Connection has been established successfully.');
})
.catch(err => {
console.error('Unable to connect to the database:', err);
});
exports.config={
sequelize:sequelize
}
const express = require('express')
const path = require('path')
require('./dbconfig.js')
const sequelize = require('../dbconfig.js')
const mediums = sequelize.define('mediums', {
medium_name: Sequelize.STRING,
langauge: Sequelize.STRING
})
module.exports = {
mediums ,
}
我已经创建了静态数据库连接字符串。但是我需要动态的数据库连接字符串。我从每个请求的网址或标头中获取数据库名称