node-mssql icon indicating copy to clipboard operation
node-mssql copied to clipboard

Feature Request: acquire single connections.

Open igalklebanov opened this issue 11 months ago • 4 comments

Hey 👋

Thanks for the awesome work people! 🙏

We're currently exploring adding mssql support @ https://github.com/kysely-org/kysely, and I have found your library very appealing. One of Kysely's API requirements is acquiring a single connection and allowing to perform multiple queries on it before releasing it back to the pool. I have read that everything is a connection pool in node-mssql, and you can only use the same connection in transactions and prepared statements. While playing around, I couldn't find a way that would allow it without doing some ugly hacks. This is a blocker, and I'm sadly switching to the low-level tedious and some resource pooling library in the dialect implementation for now. This adds more complexity (pool management, result streaming implementation, js to tedious data types mapping, etc) on our end, that would've otherwise been great to consume from node-mssql, where it fits best.

Sorry if this is a duplicate, I have scanned all issues related to "connection" and could not find anything requesting this.

Expected behavior:

A method on the connection pool that reserves a single connection and returns it. The connection allows to execute many queries and can be manually released back to the pool.

Actual behavior:

Everything is a pool in node-mssql and you can't acquire a single connection.

Configuration:

irrelevant.

Software versions

  • NodeJS: v16/18/20
  • node-mssql: v9.1.1
  • SQL Server: any

igalklebanov avatar Jul 27 '23 23:07 igalklebanov