Node-mysql2: how to start a transaction using promise version?

Created on 5 Apr 2017  路  2Comments  路  Source: sidorares/node-mysql2

Hope can support such function like below

var conn = yield mysql.createConnection(cfg);
yield conn.execute('begin');  // or yield conn.startTransaction();

but when I tried these code. I got error 'This command is not supported in the prepared statement protocol yet'.

question

Most helpful comment

yes, you can't use transactions with prepared statements.

you should be able to use yield conn.startTransaction(); with code from master ( landed in #531, not in npm yet ) or just yeld conn.query('start transaction') - beginTransaction() does exactly the same under the hood

All 2 comments

yes, you can't use transactions with prepared statements.

you should be able to use yield conn.startTransaction(); with code from master ( landed in #531, not in npm yet ) or just yeld conn.query('start transaction') - beginTransaction() does exactly the same under the hood

Thanks @sidorares , yield conn.query('start transaction') works for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abumusamq picture abumusamq  路  5Comments

AnyhowStep picture AnyhowStep  路  5Comments

SiroDiaz picture SiroDiaz  路  6Comments

jomel picture jomel  路  8Comments

patrikx3 picture patrikx3  路  7Comments