Install
Run the following command to install the connector from the root of your project:
npm install --save @latitude-data/mssql-connector
The sources files must be inside the queries/
folder.
Configuration
To configure the connection with your Microsoft SQL database follow these steps:
Create the source `.yaml` file within the `queries` folder if you haven't already
Add the following code for your Microsoft SQL connection
type: mssql
details:
user: string
password: string
database: string
server: string
pool: {
max: number
min: number
idleTimeoutMillis: number
}
options: {
encrypt: boolean
trustServerCertificate: boolean
}
Replace the details section with your info and save
Done, now you can test your connection
Attributes
- User → The username for logging into the SQL Server. It identifies the account that will be used for authentication.
- Password → The password associated with the user account for authentication purposes.
- Database → The name of the database on the SQL Server that you want to access or manipulate.
- Server → The name or IP address of the SQL Server instance you are connecting to.
- Max → (Optional) he maximum number of connections allowed in the connection pool. This is the upper limit on the number of active connections your application can have to the SQL Server at any time.
- Min → (Optional) The minimum number of connections to maintain in the pool. This ensures that a certain number of connections are always ready and available.
- IdleTimeoutMillis → (Optional) The amount of time, in milliseconds, a connection can remain idle in the pool before being closed. This helps manage and free up unused connections efficiently.
- Encrypt → (Optional) A boolean setting that determines whether the data sent between the client and SQL Server should be encrypted. This is crucial for securing sensitive data in transit.
- TrustServerCertificate → (Optional) A boolean setting that, when true, indicates the client should trust the SQL Server’s certificate without validating it. This is important for connections where SSL encryption is used but the server’s certificate may not be verified by a known Certificate Authority (CA).
Test connection
To test the connection you can:
- Create a query
.sql
in the queries
directory that points to a table of your new connection in the FROM
clause. See the section SQL Syntax Basics to learn more.
- Use the command line to run
latitude run query_file_name
where query_file_name
is the name of your .sql
file. This will display the results in your terminal. See the section Running queries to learn more about how to query your data.
Responses are generated using AI and may contain mistakes.