Registry / database / koishi-database-mysql

koishi-database-mysql

JSON →
library1.2.0jsnpmunverified

MySQL database adapter for Koishi, the cross-platform chatbot framework. Current stable version is 1.2.0, following Koishi core releases. Provides full CRUD operations for user data, group data, and message storage using MySQL. Unlike SQLite, offers better concurrency and scalability for production bots. Ships TypeScript types.

npm install koishi-database-mysql
INSTALL
IMPORT
SIG · KOISHI-DATABASE-MY
K
koishi-database-mysql
databasejavascriptv1.2.0
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 KoishiDatabaseMysql from 'koishi-database-mysql'
const KoishiDatabaseMysql = require('koishi-database-mysql')
ESM-only; CJS not supported
Database
import { Database } from 'koishi-core'
import { Database } from 'koishi-database-mysql'
Database type is from koishi-core, not this package
createMysqlDatabase
import { createMysqlDatabase } from 'koishi-database-mysql'
import createMysqlDatabase from 'koishi-database-mysql'
Named export, not default

Demonstrates creating a Koishi bot with MySQL database adapter.

import { createBot } from 'koishi-core' import { createMysqlDatabase } from 'koishi-database-mysql' const bot = createBot({ port: 8000, database: createMysqlDatabase({ host: process.env.MYSQL_HOST ?? 'localhost', port: parseInt(process.env.MYSQL_PORT ?? '3306'), user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASSWORD ?? '', database: process.env.MYSQL_DATABASE ?? 'koishi', }) }) bot.start()
Debug
Known issues
breakingkoishi-database-mysql v1.x requires koishi-core >=1.12.0
fix
Update koishi-core to ^1.12.0
affects: >=1.0.0
deprecatedThe `host` option is deprecated in favor of `connectionString` starting v1.2.0
fix
Use connectionString: 'mysql://user:pass@host:port/db'
affects: >=1.2.0
gotchaMySQL connection pool defaults to 10 connections; may exhaust under load
fix
Set poolSize option in createMysqlDatabase() to higher value
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'koishi-core'
Missing peer dependency
fix
npm install koishi-core@^1.12.0
TypeError: createMysqlDatabase is not a function
Incorrect import (default instead of named)
fix
import { createMysqlDatabase } from 'koishi-database-mysql'
ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost'
Invalid MySQL credentials
fix
Check MYSQL_USER and MYSQL_PASSWORD environment variables
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
koishi-corerequiredPeer dependency for plugin architecture and database API
Agent activity
2 hits · last 30 days
node
2
Resources
koishi-database-mysql — npm install koishi-database-mysql · libregistry