npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@remix-run/data-table-mysql

v0.5.0

Published

MySQL database implementation for remix/data-table

Readme

data-table-mysql

MySQL database driver for remix/data-table, backed by mysql2.

Features

  • Native mysql2 Integration: Creates a pool from mysql2 configuration or uses an existing pool or connection
  • Full data-table API Support: Queries, relations, writes, and transactions
  • MySQL Compiler: SQL compilation is handled automatically for MySQL
  • Multi-Statement Migrations: executeScript() runs up.sql / down.sql files via mysql2 (requires multipleStatements: true)
  • MySQL Capabilities Enabled By Default:
    • returning: false
    • savepoints: true
    • upsert: true
    • transactionalDdl: false
    • migrationLock: true

Installation

npm i remix mysql2

Usage

import { createMysqlDatabase } from 'remix/data-table/mysql'

let db = createMysqlDatabase({
  uri: process.env.DATABASE_URL,
  multipleStatements: true,
})

Use db.query(...), relation loading, and transactions from remix/data-table. Import any driver-specific types you need directly from mysql2/promise.

Database Capabilities

data-table-mysql reports this capability set by default:

  • returning: false
  • savepoints: true
  • upsert: true
  • transactionalDdl: false
  • migrationLock: true

Advanced Usage

Multi-Statement Migrations

remix/data-table/migrations sends each migration as a single multi-statement SQL script. mysql2 only accepts multi-statement scripts when the connection is created with multipleStatements: true:

import { createMysqlDatabase } from 'remix/data-table/mysql'

let db = createMysqlDatabase({
  uri: process.env.DATABASE_URL,
  multipleStatements: true,
})

Config-backed databases support db.wipe() and db.reset(). Call await db.close() during application shutdown to close the internally created pool. You may pass an existing mysql2 pool or connection when your application owns the driver lifecycle; db.close() leaves supplied clients alone, and destructive lifecycle methods are unavailable in that mode. db.wipe() requires a database name in the connection config (database, or the path of a connection URI) and throws when none is present.

Migration runs reserve one connection for the MySQL named lock, migration SQL, and journal updates. Lock acquisition waits up to 60 seconds and fails with an error instead of allowing the migration to proceed. After a successful run the connection is unlocked and returned to the pool; if the migration or unlock fails, the reserved connection is destroyed instead of being reused, so a dirty session can never leak back into the pool. Nested migration lock acquisition throws instead of deadlocking.

returning On MySQL

MySQL does not natively support SQL RETURNING. Using returning on write operations therefore throws DataTableQueryError.

Use write metadata (affectedRows, insertId) on MySQL, or switch databases when returned rows are required.

import { DataTableQueryError } from 'remix/data-table'

try {
  await db
    .query(Accounts)
    .insert({ email: '[email protected]', status: 'active' }, { returning: ['id'] })
} catch (error) {
  if (error instanceof DataTableQueryError) {
    // insert() returning is not supported by MySQL
  }
}

Running integration tests locally

To start a local MySQL container matching CI:

podman run --name mysql \
  -e MYSQL_ROOT_PASSWORD=root \
  -e MYSQL_DATABASE=remix \
  -p 3306:3306 \
  -d mysql:8

Then run:

REMIX_DATA_TABLE_MYSQL_TEST_URL=mysql://root:[email protected]:3306/remix \
pnpm test src/lib/driver.integration.test.ts

Remove the container when you are done:

podman rm -f mysql

Related Packages

License

See LICENSE