user34534
user34534

Reputation: 41

How to correctly create the connection to a local SQL Server database using TypeORM for Langchain?

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

Answers (1)

Invader
Invader

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

Related Questions