{"id":43042,"library":"meadow-connection-mysql","title":"Meadow Connection MySQL","description":"A MySQL connection pool provider for the Meadow ORM, wrapping mysql2 as a Fable service. Current stable version 1.0.19. Provides connection pooling with named placeholders, auto-connect support, and DDL generation from Meadow table schemas. Supports both Meadow-style and mysql2-native configuration formats. Notable differentiator: integrates tightly with the Fable dependency injection framework, offering auto-connect guards and schema-driven table creation. Release cadence is irregular; last release November 2023.","status":"active","version":"1.0.19","language":"javascript","source_language":"en","source_url":"https://github.com/stevenvelozo/meadow-connection-mysql","tags":["javascript","cache"],"install":[{"cmd":"npm install meadow-connection-mysql","lang":"bash","label":"npm"},{"cmd":"yarn add meadow-connection-mysql","lang":"bash","label":"yarn"},{"cmd":"pnpm add meadow-connection-mysql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for MySQL connection pooling and query execution.","package":"mysql2","optional":false},{"reason":"Required for Fable service provider integration and dependency injection.","package":"fable","optional":false}],"imports":[{"note":"Package uses CommonJS; there is no ESM export. Using import will result in a default import error.","wrong":"import MeadowConnectionMySQL from 'meadow-connection-mysql';","symbol":"MeadowConnectionMySQL","correct":"const MeadowConnectionMySQL = require('meadow-connection-mysql');"},{"note":"Fable is also CommonJS. ESM import will fail.","wrong":"import libFable from 'fable';","symbol":"libFable","correct":"const libFable = require('fable');"},{"note":"The pool instance is accessible only after registering the service with a Fable instance via serviceManager.addAndInstantiateServiceType.","wrong":"const pool = MeadowConnectionMySQL.pool;","symbol":"MeadowConnectionMySQL.pool","correct":"const pool = fable.MeadowMySQLProvider.pool;"}],"quickstart":{"code":"const libFable = require('fable');\nconst MeadowConnectionMySQL = require('meadow-connection-mysql');\n\nlet fable = new libFable({\n    MySQL: {\n        Server: '127.0.0.1',\n        Port: 3306,\n        User: 'root',\n        Password: process.env.MYSQL_PASSWORD ?? '',\n        Database: 'my_app',\n        ConnectionPoolLimit: 20\n    },\n    MeadowConnectionMySQLAutoConnect: true\n});\n\nfable.serviceManager.addAndInstantiateServiceType('MeadowMySQLProvider', MeadowConnectionMySQL);\n\nfable.MeadowMySQLProvider.pool.query('SELECT 1 AS result', (error, rows, fields) => {\n    if (error) {\n        console.error(error);\n        return;\n    }\n    console.log(`Connected: ${rows[0].result}`);\n});","lang":"javascript","description":"Initializes a Fable instance with MySQL config, adds MeadowConnectionMySQL as a service, auto-connects, and runs a test query."},"warnings":[{"fix":"Set the flag in constructor options or call fable.MeadowMySQLProvider.connect() after service registration.","message":"MeadowConnectionMySQLAutoConnect must be set to true in config or provider options to auto-connect; otherwise connect() must be called manually.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Wrap calls with util.promisify() or use a Promise wrapper: const query = util.promisify(pool.query).bind(pool);","message":"Callback-based query API: pool.query() uses callbacks. The package does not expose a Promise-based API.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Always use fable.serviceManager.addAndInstantiateServiceType('MeadowMySQLProvider', MeadowConnectionMySQL).","message":"Service must be instantiated via addAndInstantiateServiceType, not new MeadowConnectionMySQL() directly.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure logging is disabled or sanitized in production. Consider using environment variables for credentials.","message":"Password may leak in connection log messages if connection fails. The package logs descriptive errors but does not redact passwords in all cases.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Check if fable.MeadowMySQLProvider.pool exists before calling connect() again, or rely on the guard.","message":"Double-connect guard: calling connect() on an already-connected instance logs an error and does nothing. No explicit return value or callback provided.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Explicitly set ConnectionPoolLimit in config to avoid running out of connections under load.","message":"Connection pool limit default is not documented; may default to mysql2's default (10 connections).","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.19':22 '2023':79 'auto':30,63 'auto-connect':29,62 'cach':81 'cadenc':73 'configur':49 'connect':2,6,24,31,64 'creation':71 'current':19 'ddl':34 'depend':58 'differenti':52 'driven':69 'fabl':17,57 'format':50 'framework':60 'generat':35 'guard':65 'inject':59 'integr':53 'irregular':75 'javascript':80 'last':76 'meadow':1,11,37,43 'meadow-styl':42 'mysql':3,5 'mysql2':14,47 'mysql2-native':46 'name':27 'nativ':48 'notabl':51 'novemb':78 'offer':61 'orm':12 'placehold':28 'pool':7,25 'provid':8,23 'releas':72,77 'schema':39,68 'schema-driven':67 'servic':18 'stabl':20 'style':44 'support':32,40 'tabl':38,70 'tight':54 'version':21 'wrap':13","created_at":"2026-06-05T16:57:54.081654+00:00","updated_at":"2026-06-05T16:57:54.081654+00:00","problems":[{"fix":"Ensure MeadowConnectionMySQLAutoConnect: true in config, or call `fable.MeadowMySQLProvider.connect()` after addAndInstantiateServiceType.","cause":"Accessing pool.query before the service is fully registered or auto-connect disabled and connect() not called.","error":"TypeError: Cannot read properties of undefined (reading 'query')"},{"fix":"Wrap pool.query inside the callback of connectAsync, or use events to check pool status.","cause":"Calling pool.query after connection failure or before connect() completes.","error":"Error: Pool is not connected"},{"fix":"Add `authPlugins: { sha256_password: undefined }` to mysql2 connection config, or set default auth plugin to mysql_native_password on server.","cause":"MySQL server uses caching_sha2_password plugin (MySQL 8+ default) and mysql2 default auth plugin may not be configured.","error":"Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server"},{"fix":"Run: npm install fable meadow-connection-mysql (fable must be installed separately).","cause":"Missing peer dependency 'fable'.","error":"Error: Cannot find module 'fable'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/stevenvelozo/meadow-connection-mysql","github":"https://github.com/stevenvelozo/meadow-connection-mysql","docs":null,"changelog":null,"pypi":null,"npm":"meadow-connection-mysql","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}