Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the most mature/stable mysql node.js module

Tags:

I am looking to do some work around mysql and node.js and have found a few different modules out there but I cannot get a good bead on their stability/maturity. I know each author puts very hard work into each one, but for the work we're doing I need to know I've got a solid mysql foundation. The modules I've found that look pretty good are:

  1. db-mysql This appears pretty active.
  2. node-mysql This is a pretty pervasive module I've seen so far, it appears to be in a maintenance phase, and seems solid.
  3. node-mysql-native I like the async work being done here, but I'm not sure how well it works yet.
  4. node-mysql-libmysqlclient I'm not sure about this one, but it appears to be active as well.

I don't have many needs that are too far out of the ordinary. I need regular query support, extras would be nice, I just need a good foundation to start from. Any input as to the strengths and weaknesses of these modules would be great. If there is another quality contender I have not found I am not at all against considering another option.

like image 795
Jeremy B. Avatar asked Jun 14 '11 14:06

Jeremy B.


People also ask

Is Node js good with MySQL?

The aim of this article is to explain the common misconception about using MySQL with Node. js and to assure you that there is completely nothing wrong with using this database together with Node.

Does node js have an ORM?

TypeORM is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used with TypeScript and JavaScript (ES5, ES6, ES7, ES8).


2 Answers

I'm the author of node-mysql-native driver, from my point of view the differences are

  1. no prepared statements support (yet) in node-mysql
  2. according to my benchmarks node-mysql is 10-20% slower than node-mysql-native
  3. node-mysql has much wider adoption, more tests and users. If you need stability, better use it
  4. node-mysql-libmysqlclient is 2 to 3 times faster on fast queries. However, if you have a lot of slow queries and use connection pools it could be even slower than native JS driver because libmysqlclient async calls are based on nodejs thread pool and not on event loop.

update

As of 11/07/2013

  • (2). no longer valid (mysql-native is a bit slower than node-mysql)
  • have this alternative to node-mysql, on some benchmarks it's 2-3 times faster, has same API + support for prepared statements, SSL and compression. Also implements simple subset of server side protocol - see for example MySQL -> Postgres proxy.
  • node-mariasql is also a very good option (if it's ok to use binary addon) - fast, stable, async, prepared statements support, compression and SSL.
like image 62
Andrey Sidorov Avatar answered Oct 04 '22 22:10

Andrey Sidorov


I went through a similar search and ended up settling on node-mysql. I like it's simplicity, the fact that it's pure js, and that it's well supported. It was slower in tests that I did than some of the mixed modules (those that used non-js libs), but I did a minor patch that helped considerably with that for my cases:

https://github.com/geochap/node-mysql

like image 37
Geoff Chappell Avatar answered Oct 04 '22 21:10

Geoff Chappell