using connection.query(...).stream() with promise wrapper
See original GitHub issuewhy can’t I use connection.query(...).stream()
with promise wrapper?
(you get error: TypeError: connection.query(…).stream is not a function)
I’d quite like to be able to do:
let q = await connection.query(someSQL);
as well as
const s1 = connection.query(veryBiqSqlResult).stream();
s1.on('result', async function(row) {...})
in the same script, but atm I need promise api for the first and standard api for the second…
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (5 by maintainers)
Top Results From Across the Web
Node MySQL 2 | node-mysql2
Node MySQL 2 ; History and Why MySQL2; Installation ; First Query; Using Prepared Statements ; Using connection pools; Using Promise Wrapper ;...
Read more >promise-mysql - npm
Promise -mysql is a wrapper for mysqljs/mysql that wraps function calls with Bluebird promises. API. mysql.createConnection(connectionOptions).
Read more >ERR_STREAM_WRITE_AFTER_...
util. promisify wraps a function that expects an (err, data) callback, converting it into an async function that returns a promise instead. ...
Read more >Query Stream with MariaDB Connector/Node.js (Promise API)
Unlike most of the other Promise API functions, the queryStream() function does not return a Promise object, and therefore the value returned from...
Read more >Creating Snowflakes SDK wrapper for NodeJS API - Medium
Now connection.connect will create connection as per the below code private method. private connectSnowflake = async (req: any): Promise<any> ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
maybe we need to wait for async generators to land: http://node.green/#ESNEXT-candidate--stage-3--Asynchronous-Iterators-for-await-of-loops
( not sure if I can mix buffering
.query() => Promise version
with non-buffering detecting that .stream() is added, maybe we need another name: `for await (const row of connection.queryStream(veryBiqSqlResult)) {})You can access non-promise api from wrapper as
connection.connection
- see https://github.com/sidorares/node-mysql2/blob/97a88530db72c656c16f071a710701ad2830b38d/promise.js#L55@eyalroth I have no idea… I think the docs are a little unclear on this. In case you’re interested, I have asked a somewhat similar question here: https://github.com/mysqljs/mysql/issues/2523