meteor-mysql icon indicating copy to clipboard operation
meteor-mysql copied to clipboard

Manage (open/close) multiple mysql connections

Open sushitommy opened this issue 9 years ago • 2 comments

If you have different templates that have to connect to different mysql databases. What's the best approach to (re)use multiple liveDB instances?

  • Create a new liveDB for every subscription and close it onStop
  • Reuse a global liveDB var
  • Reuse a liveDB var that is retrieved from a connection manager.
  • Use the node-mysql connection pool (possible?)

Right now I'm using option 1: I use the Template.OnDestroyed function to stop the mysql connection if a user navigates away from the page where it's used. However, I'm also using a dynamic subscription which also calls the same subscription.stop(). So on every change, a new liveDB connection object is created. What are your ideas?

sushitommy avatar Aug 26 '15 14:08 sushitommy

Why would you use different connections for different databases? It is not required to specify a database in the connection settings.

numtel avatar Aug 27 '15 17:08 numtel

Ow I mean different mysql servers! On Aug 27, 2015 7:00 PM, "Ben Green" [email protected] wrote:

Why would you use different connections for different databases? It is not required to specify a database in the connection settings.

— Reply to this email directly or view it on GitHub https://github.com/numtel/meteor-mysql/issues/31#issuecomment-135493105.

sushitommy avatar Aug 28 '15 07:08 sushitommy