Can Node JS connect to MongoDB and mySQL simultaneously?












1















I have a developer that says Node JS can only connect to multiple databases on the same server. I would like her to be able to connect to MongoDB and mySQL at the same time ... Is it possible? And can you either provide some example code or point me to the proper documentation to do so? Thx!










share|improve this question


















  • 2





    It's difficult to even imagine what the developer may be thinking, to come to this conclusion. It honestly seems too straightforward for there to even exist documentation on how to do it -- you just write the code to connect to one, then write the code to connect to the other, then use those connections as needed. Using both is no different than only using one or the other. Did she say why she believes otherwise, or in what sense it wouldn't work? (Since they don't use the same library, they shouldn't interact negatively at all.) Can you get any more info/clarification on this?

    – Michael - sqlbot
    Jan 17 at 3:46













  • Thanks, Michael ... this is as I suspected. She knows that you can conenct to two databases but thinks they need to be the same kind of DB ... both MongoDB for example.

    – OregonDean
    Jan 17 at 16:31
















1















I have a developer that says Node JS can only connect to multiple databases on the same server. I would like her to be able to connect to MongoDB and mySQL at the same time ... Is it possible? And can you either provide some example code or point me to the proper documentation to do so? Thx!










share|improve this question


















  • 2





    It's difficult to even imagine what the developer may be thinking, to come to this conclusion. It honestly seems too straightforward for there to even exist documentation on how to do it -- you just write the code to connect to one, then write the code to connect to the other, then use those connections as needed. Using both is no different than only using one or the other. Did she say why she believes otherwise, or in what sense it wouldn't work? (Since they don't use the same library, they shouldn't interact negatively at all.) Can you get any more info/clarification on this?

    – Michael - sqlbot
    Jan 17 at 3:46













  • Thanks, Michael ... this is as I suspected. She knows that you can conenct to two databases but thinks they need to be the same kind of DB ... both MongoDB for example.

    – OregonDean
    Jan 17 at 16:31














1












1








1








I have a developer that says Node JS can only connect to multiple databases on the same server. I would like her to be able to connect to MongoDB and mySQL at the same time ... Is it possible? And can you either provide some example code or point me to the proper documentation to do so? Thx!










share|improve this question














I have a developer that says Node JS can only connect to multiple databases on the same server. I would like her to be able to connect to MongoDB and mySQL at the same time ... Is it possible? And can you either provide some example code or point me to the proper documentation to do so? Thx!







mysql node.js mongodb






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 16 at 23:49









OregonDeanOregonDean

62




62








  • 2





    It's difficult to even imagine what the developer may be thinking, to come to this conclusion. It honestly seems too straightforward for there to even exist documentation on how to do it -- you just write the code to connect to one, then write the code to connect to the other, then use those connections as needed. Using both is no different than only using one or the other. Did she say why she believes otherwise, or in what sense it wouldn't work? (Since they don't use the same library, they shouldn't interact negatively at all.) Can you get any more info/clarification on this?

    – Michael - sqlbot
    Jan 17 at 3:46













  • Thanks, Michael ... this is as I suspected. She knows that you can conenct to two databases but thinks they need to be the same kind of DB ... both MongoDB for example.

    – OregonDean
    Jan 17 at 16:31














  • 2





    It's difficult to even imagine what the developer may be thinking, to come to this conclusion. It honestly seems too straightforward for there to even exist documentation on how to do it -- you just write the code to connect to one, then write the code to connect to the other, then use those connections as needed. Using both is no different than only using one or the other. Did she say why she believes otherwise, or in what sense it wouldn't work? (Since they don't use the same library, they shouldn't interact negatively at all.) Can you get any more info/clarification on this?

    – Michael - sqlbot
    Jan 17 at 3:46













  • Thanks, Michael ... this is as I suspected. She knows that you can conenct to two databases but thinks they need to be the same kind of DB ... both MongoDB for example.

    – OregonDean
    Jan 17 at 16:31








2




2





It's difficult to even imagine what the developer may be thinking, to come to this conclusion. It honestly seems too straightforward for there to even exist documentation on how to do it -- you just write the code to connect to one, then write the code to connect to the other, then use those connections as needed. Using both is no different than only using one or the other. Did she say why she believes otherwise, or in what sense it wouldn't work? (Since they don't use the same library, they shouldn't interact negatively at all.) Can you get any more info/clarification on this?

– Michael - sqlbot
Jan 17 at 3:46







It's difficult to even imagine what the developer may be thinking, to come to this conclusion. It honestly seems too straightforward for there to even exist documentation on how to do it -- you just write the code to connect to one, then write the code to connect to the other, then use those connections as needed. Using both is no different than only using one or the other. Did she say why she believes otherwise, or in what sense it wouldn't work? (Since they don't use the same library, they shouldn't interact negatively at all.) Can you get any more info/clarification on this?

– Michael - sqlbot
Jan 17 at 3:46















Thanks, Michael ... this is as I suspected. She knows that you can conenct to two databases but thinks they need to be the same kind of DB ... both MongoDB for example.

– OregonDean
Jan 17 at 16:31





Thanks, Michael ... this is as I suspected. She knows that you can conenct to two databases but thinks they need to be the same kind of DB ... both MongoDB for example.

– OregonDean
Jan 17 at 16:31










1 Answer
1






active

oldest

votes


















1














As Michael said, you can do it by asynchronously connecting to the two databases. Node.js has non-blocking async I/O, which means that you can perform operations on the MongoDB database without waiting for other operations to finish running (and vice versa). You can read more on this here, and in the mongoose and mysql docs.






share|improve this answer
























  • Thanks, Itai for the async information, we are using the databases independently so this is exactly our situation.

    – OregonDean
    Jan 17 at 16:33











  • If my answer answered your question feel free to mark it as approved :)

    – Itai Steinherz
    Jan 17 at 16:36













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1395165%2fcan-node-js-connect-to-mongodb-and-mysql-simultaneously%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














As Michael said, you can do it by asynchronously connecting to the two databases. Node.js has non-blocking async I/O, which means that you can perform operations on the MongoDB database without waiting for other operations to finish running (and vice versa). You can read more on this here, and in the mongoose and mysql docs.






share|improve this answer
























  • Thanks, Itai for the async information, we are using the databases independently so this is exactly our situation.

    – OregonDean
    Jan 17 at 16:33











  • If my answer answered your question feel free to mark it as approved :)

    – Itai Steinherz
    Jan 17 at 16:36


















1














As Michael said, you can do it by asynchronously connecting to the two databases. Node.js has non-blocking async I/O, which means that you can perform operations on the MongoDB database without waiting for other operations to finish running (and vice versa). You can read more on this here, and in the mongoose and mysql docs.






share|improve this answer
























  • Thanks, Itai for the async information, we are using the databases independently so this is exactly our situation.

    – OregonDean
    Jan 17 at 16:33











  • If my answer answered your question feel free to mark it as approved :)

    – Itai Steinherz
    Jan 17 at 16:36
















1












1








1







As Michael said, you can do it by asynchronously connecting to the two databases. Node.js has non-blocking async I/O, which means that you can perform operations on the MongoDB database without waiting for other operations to finish running (and vice versa). You can read more on this here, and in the mongoose and mysql docs.






share|improve this answer













As Michael said, you can do it by asynchronously connecting to the two databases. Node.js has non-blocking async I/O, which means that you can perform operations on the MongoDB database without waiting for other operations to finish running (and vice versa). You can read more on this here, and in the mongoose and mysql docs.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 17 at 14:44









Itai SteinherzItai Steinherz

1334




1334













  • Thanks, Itai for the async information, we are using the databases independently so this is exactly our situation.

    – OregonDean
    Jan 17 at 16:33











  • If my answer answered your question feel free to mark it as approved :)

    – Itai Steinherz
    Jan 17 at 16:36





















  • Thanks, Itai for the async information, we are using the databases independently so this is exactly our situation.

    – OregonDean
    Jan 17 at 16:33











  • If my answer answered your question feel free to mark it as approved :)

    – Itai Steinherz
    Jan 17 at 16:36



















Thanks, Itai for the async information, we are using the databases independently so this is exactly our situation.

– OregonDean
Jan 17 at 16:33





Thanks, Itai for the async information, we are using the databases independently so this is exactly our situation.

– OregonDean
Jan 17 at 16:33













If my answer answered your question feel free to mark it as approved :)

– Itai Steinherz
Jan 17 at 16:36







If my answer answered your question feel free to mark it as approved :)

– Itai Steinherz
Jan 17 at 16:36




















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1395165%2fcan-node-js-connect-to-mongodb-and-mysql-simultaneously%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

is 'sed' thread safe

How to make a Squid Proxy server?