Closed syco closed 1 year ago
This module does not officially support MariaDB, but it should work as long as you are using a version of MariaDB that is compatible with MySQL 5.7
Can you please post the code where you are using this module?
This are the relevant pieces in my app.js
const session = require('express-session');
const MySQLStore = require('express-mysql-session')(session);
const ma_sql = require(path.join(__dirname, "libs", "db.ma.js"));
const sessionStore = new MySQLStore({}, ma_sql);
app.use(session({
cookie: {
sameSite: true,
secure: false
},
maxAge: 7200000,
resave: false,
rolling: true,
saveUninitialized: false,
secret: 'xxx',
store: sessionStore
}));
I believe the problem is that table names and column names cannot be wrapped in single/double quotes in mariadb.
So when you use ??
to replace the table name and the columns, it build an invalid query.
Can I ask why you use '??' instead of '?' ? I'm not familiar with this syntax. Thanks
Ok, I guess I found it: https://github.com/mariadb-corporation/mariadb-connector-nodejs/issues/108
in here they say ??
is not supported and needs to be done manually.
This module does not support custom MySQL node clients. Please use the mysql2's promise interface - e.g. from the usage section in the readme:
const mysql = require('mysql2/promise');
const session = require('express-session');
const MySQLStore = require('express-mysql-session')(session);
const options = {
host: 'localhost',
port: 3306,
user: 'db_user',
password: 'password',
database: 'db_name'
};
const connection = mysql.createConnection(options); // or mysql.createPool(options);
const sessionStore = new MySQLStore({}/* session store options */, connection);
I believe the problem is that table names and column names cannot be wrapped in single/double quotes in mariadb. So when you use
??
to replace the table name and the columns, it build an invalid query.
Yes, the column and table names can (and should) be specified with double-question marks because MariaDB is theoretically compatible with MySQL.
Can I ask why you use '??' instead of '?' ? I'm not familiar with this syntax. Thanks
Double-question marks indicate that the value inserted should be escaped as an identifier - ie. a column or table name.
Hi I'm trying to get this to work on mariadb 10.11.4 on debian 12, but I get the following error, any help appreciated.
Thanks.