Comments (11)
from nodejs-idb-pconnector.
Obviously it counts in hex 😂
from nodejs-idb-pconnector.
The above statement creates 16 connections. Is this expected?
@oneworks That is not expected, it should create 10 connections.
I tried to recreate the issue with:
const {DBPool} = require('idb-pconnector');
const pool = new DBPool({ url: "*LOCAL" }, { debug: true , incrementSize: 10});
console.log(`Pool contains: ${pool.connections.length} connections`);
my output was
Creating Connection 0...
Connection 0 created
Creating Connection 1...
Connection 1 created
Creating Connection 2...
Connection 2 created
Creating Connection 3...
Connection 3 created
Creating Connection 4...
Connection 4 created
Creating Connection 5...
Connection 5 created
Creating Connection 6...
Connection 6 created
Creating Connection 7...
Connection 7 created
Creating Connection 8...
Connection 8 created
Creating Connection 9...
Connection 9 created
Pool contains: 10 connections
I'm only seeing 10 connections created.
Are you redirecting stdout
to a log file?
When you have debug set to true then Creating connection output is printed at startup each time.
from nodejs-idb-pconnector.
from nodejs-idb-pconnector.
Looks to me that output from your node app is being appended each time to that file.
Seems like it was run twice.
Creating Connection 0...
Connection 0 created
Creating Connection 1...
Connection 1 created
Creating Connection 2...
Connection 2 created
Creating Connection 3...
Connection 3 created
Creating Connection 4...
Connection 4 created
Creating Connection 5...
Connection 5 created
Creating Connection 6...
Connection 6 created
Connection 7 created
Creating Connection 8...
Connection 8 created
Creating Connection 9...
Connection 9 created
Creating Connection 0...
Connection 0 created
Creating Connection 1...
Connection 1 created
Creating Connection 2...
Connection 2 created
Creating Connection 3...
Connection 3 created
Creating Connection 4...
Connection 4 created
Creating Connection 5...
Connection 5 created
Creating Connection 6...
Connection 6 created
Creating Connection 7...
Connection 7 created
What weird is that output ends after connection 7 was created.
Is the above output the full log from the file?
from nodejs-idb-pconnector.
from nodejs-idb-pconnector.
In this case why not just use DBPool.runSql()
directly within the post route?
I think that would be more efficient and simpler than wrapping with the helper script.
from nodejs-idb-pconnector.
from nodejs-idb-pconnector.
FYI, DBPool provides a prepare, bind, and execute helper: DBPool.prepareExecute().
I would highly recommend using helper functions provided:
DBPool.runSql()
DBPool.prepareExecute()
directly instead of recreating that functionality
If you wanted to stick to using db_promise.js
helper script I would only require DBPool
within that file.
So that you avoid creating unused connections.
from nodejs-idb-pconnector.
from nodejs-idb-pconnector.
For your first question, yes that will create 10 connections. But when you call 'require('x');', node retuns the exact same object in each file. Using this behavior, we create a file, something like pool.js
, and then do your pool initialization there:
const { DBPool } = require("idb-pconnector");
const pool = new DBPool({ url: "*LOCAL" }, { debug: true, incrementSize: 10 });
module.exports = pool;
Then, in all your other files, you can have:
...
const pool = require('./pool');
...
This will share the same pool object in all your files, so you only create 10 connections and not 10 x # of files.
As for your second question, I'm accustomed to only using the UPPERCASE variables. @abmusse might know if there's some configuration option.
from nodejs-idb-pconnector.
Related Issues (20)
- setLibraryList and sql user defined functions HOT 5
- dbpool failed to detach HOT 19
- Run linter during PR HOT 1
- Fix eslint errors
- Max number of simultaneous connections HOT 8
- Drop standard-version as its now deprecated HOT 2
- Calling Store Proc passing well IN parms , not getting OUT parm HOT 2
- DBPool example is incomplete.. HOT 1
- Please make more clear how to call a Stored Procedure HOT 7
- No clear explanation on how to call stored procedure. Not receiving output.
- More examples HOT 5
- bindParam() is deprecated and you should use bindParameters() instead HOT 8
- Fix copyright headers on source files
- Add package-lock.json HOT 1
- DBPool 'new connection' event emitter issues HOT 1
- build: Add standard-version HOT 1
- Migrate docs to readthedocs HOT 1
- Add exempt-pr-label
- DBPool.prepareExecute should provide a way to enable numeric type conversion HOT 7
- fetchAll keys lower case HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-idb-pconnector.