{"id":42608,"library":"dbfixtures-mysql-driver","title":"DB Fixtures MySQL Driver","description":"A MySQL driver for the dbfixtures package, providing an abstraction layer over the mysql package to facilitate handling database fixtures for testing. Current stable version is 1.2.0. It supports Node.js v8 or higher (with harmony_promise_finally flag for v8 and v9). It can be used standalone or with dbfixtures. Key differentiator: integrates seamlessly with the dbfixtures ecosystem, offering truncate, insertFixtures, and close methods while handling foreign key constraints. Not actively maintained (last release appears old).","status":"maintenance","version":"1.2.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/PedroHenriques/dbfixtures-mysql-driver","tags":["javascript","db fixtures","test fixtures","fixtures","typescript"],"install":[{"cmd":"npm install dbfixtures-mysql-driver","lang":"bash","label":"npm"},{"cmd":"yarn add dbfixtures-mysql-driver","lang":"bash","label":"yarn"},{"cmd":"pnpm add dbfixtures-mysql-driver","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Underlying MySQL driver used for database operations","package":"mysql","optional":false}],"imports":[{"note":"ESM import uses default export; CommonJS uses require without .default.","wrong":"const fixturesMysqlDriver = require('dbfixtures-mysql-driver').default","symbol":"default","correct":"import fixturesMysqlDriver from 'dbfixtures-mysql-driver'"},{"note":"Named export 'create' is available for ESM.","wrong":"const create = require('dbfixtures-mysql-driver').create","symbol":"create","correct":"import { create } from 'dbfixtures-mysql-driver'"},{"note":"IDriver is a TypeScript type; import it as a type to avoid runtime errors.","wrong":"import { IDriver } from 'dbfixtures-mysql-driver'","symbol":"IDriver","correct":"import type { IDriver } from 'dbfixtures-mysql-driver'"}],"quickstart":{"code":"import dbfixtures from 'dbfixtures';\nimport fixturesMysqlDriver from 'dbfixtures-mysql-driver';\n\nconst mysqlConnectionInfo = {\n  host: 'localhost',\n  port: '3306',\n  user: 'root',\n  password: process.env.DB_PASSWORD ?? ''\n};\n\nconst fixtures = {\n  'users': [\n    { id: 1, name: 'Alice' },\n    { id: 2, name: 'Bob' }\n  ]\n};\n\nasync function runFixtures() {\n  const driver = await fixturesMysqlDriver.create(mysqlConnectionInfo);\n  dbfixtures.setDrivers(driver);\n  await dbfixtures.truncateTables(['users']);\n  await dbfixtures.insertFixtures(fixtures);\n  console.log('Fixtures loaded');\n  await dbfixtures.closeDrivers();\n}\nrunFixtures();","lang":"typescript","description":"Demonstrates how to create a MySQL driver, set it on dbfixtures, truncate tables, insert fixtures, and close the connection."},"warnings":[{"fix":"Use Node.js v10+ or run with --harmony_promise_finally flag.","message":"Node.js v8 and v9 require --harmony_promise_finally flag for this package (versions >=1.1.0).","severity":"gotcha","affected_versions":">=1.1.0"},{"fix":"Upgrade to 1.1.0+ and use Node v8+.","message":"Version 1.0.x supported Node v7 only; 1.1.0 dropped v7 support.","severity":"breaking","affected_versions":"1.0.x"},{"fix":"Ensure build tools (e.g., gcc, python) are installed for native modules.","message":"Package depends on mysql package, which is not a pure JavaScript driver and may require native compilation.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Switch to dbfixtures-mysql2-driver if available or use mysql2 directly.","message":"mysql package is considered deprecated; consider migrating to mysql2.","severity":"deprecated","affected_versions":">=1.2.0"},{"fix":"Validate connection options before calling create().","message":"create() expects a ConnectionOptions object or DSN string; invalid options cause silent failures.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'1.2.0':31 'abstract':14 'activ':75 'appear':79 'close':67 'constraint':73 'current':27 'databas':23 'db':1,82 'dbfixtur':10,54,61 'differenti':56 'driver':4,7 'ecosystem':62 'facilit':21 'final':41 'fixtur':2,24,83,85,86 'flag':42 'foreign':71 'handl':22,70 'harmoni':39 'higher':37 'insertfixtur':65 'integr':57 'javascript':81 'key':55,72 'last':77 'layer':15 'maintain':76 'method':68 'mysql':3,6,18 'node.js':34 'offer':63 'old':80 'packag':11,19 'promis':40 'provid':12 'releas':78 'seamless':58 'stabl':28 'standalon':51 'support':33 'test':26,84 'truncat':64 'typescript':87 'use':50 'v8':35,44 'v9':46 'version':29","created_at":"2026-06-05T16:55:48.861831+00:00","updated_at":"2026-06-05T16:55:48.861831+00:00","problems":[{"fix":"Use `const fixturesMysqlDriver = require('dbfixtures-mysql-driver')` (no .default) or ESM import.","cause":"Importing the module incorrectly and getting the default export as undefined.","error":"TypeError: fixturesMysqlDriver.create is not a function"},{"fix":"Run `npm install mysql` as a dependency.","cause":"mysql package not installed or not found.","error":"Cannot find module 'mysql'"},{"fix":"Check connection options (host, port, user, password) and ensure MySQL server is running.","cause":"Invalid MySQL credentials provided.","error":"ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost'"},{"fix":"Upgrade to Node v10+ or run with --harmony_promise_finally flag.","cause":"Using Node.js v8 or v9 without the flag.","error":"Node.js flag --harmony_promise_finally is required"}],"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/PedroHenriques/dbfixtures-mysql-driver","github":"ssh://git@github.com/PedroHenriques/dbfixtures-mysql-driver","docs":null,"changelog":null,"pypi":null,"npm":"dbfixtures-mysql-driver","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","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}}