Reputation: 41
I am trying to connect to my local SQL Server database to use it with Langchain. This is how I am trying to create the connection but keep getting the error shown below when fromDataSourceParams runs:
const datasource = new DataSource({
type: 'mssql',
host: 'localhost',
username: '',
password: '',
database: 'DB',
logging: true,
extra: { trustServerCertificate: true },
});
const db = await SqlDatabase.fromDataSourceParams({ appDataSource: datasource });
err = new ConnectionError(err)
ConnectionError: Login failed for user ''.
What am I doing wrong when am I creating the connection?
Tried to use my Windows credentials for username and password and be able to connect to the database.
Upvotes: 0
Views: 143
Reputation: 679
I have established db connection as below
datasource = new DataSource({
type: "mssql",
host: this.sqlserverhost,
port: this.sqlPort,
database: this.sqldb,
username: this.sqlusername,
password: this.sqlpwd,
domain: this.sqlDomain,
options: {
trustedConnection: true,
},
extra: {
trustServerCertificate: true,
},
});
specify the domain and local host
Upvotes: 0