Registry / database / mysql-core

mysql-core

JSON →
library0.1.16jsnpmunverified

MySQL client library for Node.js and TypeScript (v0.1.16). Lightweight, type-safe wrapper around mysql2 with minimal overhead. Releases are infrequent and pre-1.0. Differentiates from mysql2 by providing first-class TypeScript types and a cleaner API, but is immature and may have breaking changes.

npm install mysql-core
INSTALL
IMPORT
SIG · MYSQL-CORE
M
mysql-core
databasejavascriptv0.1.16
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import mysql from 'mysql-core'
CommonJS require is deprecated since v0.1.10
Connection
import { Connection } from 'mysql-core'
import Connection from 'mysql-core/connection'
Named export, not default from subpath.
Pool
import { Pool } from 'mysql-core'
import { Pool } from 'mysql-core/pool'

Creates a MySQL connection, runs a simple query, and logs the result.

import mysql from 'mysql-core'; const connection = mysql.createConnection({ host: 'localhost', user: 'root', password: process.env.DB_PASSWORD ?? '', database: 'test' }); connection.query('SELECT 1 + 1 AS solution', (err, results) => { if (err) throw err; console.log(results[0].solution); }); connection.end();
Debug
Known issues
breakingPre-1.0 releases may have breaking changes without major version bump.
fix
Pin to exact version in package.json.
affects: <1.0.0
gotchaRequires mysql2 as a peer dependency; must be installed separately.
fix
Run 'npm install mysql2' in your project.
affects: >=0.1.0
deprecatedCommonJS require() is deprecated since v0.1.10, use ESM imports.
fix
Use 'import mysql from 'mysql-core'' instead of 'const mysql = require('mysql-core')'.
affects: >=0.1.10
gotchaTypes are included but may not cover all mysql2 features (e.g., prepare statements).
fix
Check the type definitions for completeness.
affects: <0.2.0
Errors
Common errors & fixes
Cannot find module 'mysql2'
mysql2 not installed as peer dependency
fix
npm install mysql2
TypeError: mysql.createConnection is not a function
Using default import as CommonJS require
fix
Use import mysql from 'mysql-core' or const mysql = require('mysql-core').default
This expression is not constructable. Type 'typeof import("mysql-core")' has no construct signatures.
Trying to new mysql() instead of using createConnection
fix
Use mysql.createConnection(...)
Upgrade
Version history
0.1.16latest on npm
Audit
Dependencies
mysql2requiredcore dependency for MySQL protocol handling
Agent activity
4 hits · last 30 days
node
4
Resources
mysql-core — npm install mysql-core · libregistry