Building SQL QueriesDocumentation

Getting started with MySQL and Node.js

The @databases/mysql library provides a safe and convenient API for querying MySQL databases in node.js.

Top tip: If you haven't done so already, you may want to set up syntax highighting in your editor then resume this guide when you've done that.

Getting Started

If you're new to @databases, the best way to start is by following our guide in order:

  1. Installation & Setup - install @databases/mysql and run your first query

  2. Managing Connections - manage the connection pool and connection configuration securely

  3. Querying Postgres - perform CRUD (create, read, update, delete) operations in Postgres

  4. Using Transactions - isolate concurrent queries using transactions

  5. TypeScript - generate TypeScript types for your database tables

TypeScript vs. JavaScript

If you're using TypeScript or babel, you can use the modern import createConnectionPool from '@databases/mysql' syntax. If your environment doesn't support this syntax, you should select "JavaScript" to view code samples with the legacy CommonJS require style:

import createConnectionPool from '@databases/mysql';
Heroku
Installation & Setup