Connect to a local SQL Server db with sequelize

前端 未结 1 1678
迷失自我
迷失自我 2021-01-16 11:08

Having completed the SQL Server installer, the given connection string is Server=localhost\\MSSQLSERVER01;Database=master;Trusted_Connection=True;, which seems

相关标签:
1条回答
  • 2021-01-16 11:30

    Based on this article you should install sequelize-msnodesqlv8:

    var sequelize = new Sequelize({
      dialect: 'mssql',
      dialectModulePath: 'sequelize-msnodesqlv8',
      dialectOptions: {
        instanceName: 'MSSQLSERVER01',
        trustedConnection: true
      },
      host: 'localhost',
      database: 'master'
    });
    

    or perhaps better:

    var sequelize = new Sequelize({
      dialect: 'mssql',
      dialectModulePath: 'sequelize-msnodesqlv8',
      dialectOptions: {
        connectionString: 'Server=localhost\MSSQLSERVER01;Database=master; Trusted_Connection=yes;'
      },
    });
    

    But you should not leave default database as Master. Use your database name instead.

    Mark this:

    There are many node mssql clients and sequelize defaults to using tedious, but being pure javascript,tedious lacks support for integrated security. msnodesqlv8 is a client that interfaces with a native odbc library. This allows integrated security to be used. It does require additional binaries to deploy, but fortunately, msnodesqlv8 is distributed with binaries for the most common architectures

    You are using integrated security, so you need to deal with that problem.

    See also this question.

    0 讨论(0)
提交回复
热议问题