No, it doesn't matter which you use. MariaDB is backwards compatible with MySQL. You could even connect to MySQL with node-mariasql if you wanted.
Node-mysql with mariadb
Question
I already use mariadb as a mysql server. However, I'm not sure using a node package designed for mysql is a good idea to use for mariadb.
There are actually two node packages:
- For mscdex/node-mariasql
- For mysqljs/mysql
I currently use mysql, since it seems pretty mature and maintained. It also seems to work well with mariadb on my side.
Are there any restrictions/incompatibilities/security issues to use mysqljs/mysql over mscdex/node-mariasql for a mariadb server?
Thanks
Solution
OTHER TIPS
Hi i am currently working on project with Maria DB and i am using node-mysql for production. It works really well for me. Reason of not using node-mariadb is the number of ratings and maturity of package.
I used mariasql
in the past. It didn't cast fields to their proper JS type. Everything came back as a string (even integers). I'm going to try out the mysql
driver. Seems weird that I have to use a different connection for each query if I want to do it in parallel. Seems like that should be abstracted for me.
Use this code my be helpfull for xampp mysql connection by using NodeJS
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '',
database : '<database name>'
});
connection.connect(function(err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
else{
console.log("database has been connected");
}
});
var queryString = 'SELECT * FROM <table name>';
connection.query(queryString, function(err, rows, fields) {
if (err) throw err;
for (var i in rows) {
console.log('filesname: ', rows[i].fieldname);
}
});
connection.end();
My impression of node-mariasql is that it is immature in terms of supporting all database operations (especially prepared insert operations are lackluster atm) and also documentation is poor. I'd suggest using node-mysql for production applications.