mysql
A pure node.js JavaScript Client implementing the MySQL protocol.
A Node.js library that lets JavaScript applications connect to and query MySQL databases, with built-in connection pooling, SQL injection protection, and support for streaming large result sets.
This is a Node.js driver for MySQL databases — a library that lets JavaScript applications running in Node.js connect to and query a MySQL database. It is written entirely in JavaScript, requires no native compilation, and is MIT-licensed.
The library handles the full range of database operations: establishing connections, running queries, inserting and retrieving data, managing transactions, and handling errors. It supports connection pooling, which means instead of opening a new database connection for every request, a pool of connections is kept ready and reused, which improves performance in web applications handling many simultaneous users.
Security is handled through automatic escaping of values and identifiers passed into queries, which prevents a common attack called SQL injection. The library also supports streaming large result sets row by row rather than loading everything into memory at once. It is installed via npm and works in any Node.js environment.
Where it fits
- Connect a Node.js web app to a MySQL database to read and write data
- Use connection pooling to handle many simultaneous users without opening a new database connection for each request
- Safely insert user-provided form data into MySQL without risk of SQL injection attacks
- Stream large query results row by row instead of loading everything into memory at once