{"id":16396,"library":"immutable-database-mariasql","title":"Immutable MariaDB/MySQL Driver","description":"This package is a Node.js database driver designed to interface with MariaDB and MySQL, specifically adapted for 'immutable-core' concepts, meaning it encourages or facilitates an append-only data pattern. It requires Node.js v7.6.0 or higher for native async/await support. However, `immutable-database-mariasql` appears to be a wrapper around the `mariasql` package, which itself is highly outdated, having been last published over a decade ago (version 0.2.6, April 2016). Due to its reliance on a deprecated and unmaintained underlying library, this package is effectively abandoned and should not be used for new development. Its 'immutable' aspect is likely implemented at the application or wrapper level, as MariaDB/MySQL are not inherently immutable databases. For modern Node.js applications connecting to MariaDB or MySQL, the actively maintained `@mariadb/mariadb-connector-nodejs` (npm `mariadb`) is the recommended alternative.","status":"abandoned","version":"1.3.47","language":"javascript","source_language":"en","source_url":"https://github.com/warncke/immutable-database-mariasql","tags":["javascript"],"install":[{"cmd":"npm install immutable-database-mariasql","lang":"bash","label":"npm"},{"cmd":"yarn add immutable-database-mariasql","lang":"bash","label":"yarn"},{"cmd":"pnpm add immutable-database-mariasql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is a wrapper around `mariasql`, which is its core database interaction layer.","package":"mariasql","optional":false}],"imports":[{"note":"This package, and its underlying `mariasql` dependency, primarily utilized CommonJS `require` syntax. Native ES Modules (`import`) are unlikely to be fully supported or stable due to the package's age and its Node.js v7.6.0 target.","wrong":"import { Client } from 'immutable-database-mariasql';","symbol":"Client","correct":"const { Client } = require('immutable-database-mariasql');"},{"note":"As an older package, `immutable-database-mariasql` does not ship with TypeScript type definitions, nor does its underlying `mariasql` dependency. Options are passed as plain JavaScript objects.","symbol":"ConnectionOptions","correct":"// Type definitions are generally not available for this package. Refer to documentation for object structure."}],"quickstart":{"code":"const { Client } = require('immutable-database-mariasql');\n\nconst client = new Client({\n  host: process.env.DB_HOST ?? 'localhost',\n  user: process.env.DB_USER ?? 'root',\n  password: process.env.DB_PASSWORD ?? '',\n  db: process.env.DB_NAME ?? 'test_db',\n  charset: 'utf8mb4'\n});\n\nasync function runImmutableExample() {\n  try {\n    await client.connect();\n    console.log('Connected to MariaDB/MySQL.');\n\n    // Create a table for immutable logs if it doesn't exist (example for 'immutable' pattern)\n    await client.query(`\n      CREATE TABLE IF NOT EXISTS audit_log (\n        id INT AUTO_INCREMENT PRIMARY KEY,\n        action VARCHAR(255) NOT NULL,\n        user_id INT NOT NULL,\n        timestamp DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n        data JSON,\n        superseded_id INT NULL\n      );\n    `);\n    console.log('Ensured audit_log table exists.');\n\n    // Demonstrate 'immutable' insert: adding a new record instead of updating\n    const insertResult = await client.query(\n      'INSERT INTO audit_log (action, user_id, data) VALUES (?, ?, ?)',\n      ['USER_CREATED', 101, JSON.stringify({ username: 'alice', email: 'alice@example.com' })]\n    );\n    console.log('New user log entry:', insertResult.info.affectedRows);\n\n    // When data conceptually 'changes', a new log entry is created.\n    // The previous entry can be referenced as 'superseded'.\n    const previousLog = (await client.query('SELECT id FROM audit_log WHERE user_id = ? ORDER BY id DESC LIMIT 1', [101]))[0];\n    const updateLogResult = await client.query(\n      'INSERT INTO audit_log (action, user_id, data, superseded_id) VALUES (?, ?, ?, ?)',\n      ['USER_EMAIL_UPDATED', 101, JSON.stringify({ email: 'alice.new@example.com' }), previousLog ? previousLog.id : null]\n    );\n    console.log('User email update log entry:', updateLogResult.info.affectedRows);\n\n    // Querying the full history for a user\n    const history = await client.query('SELECT * FROM audit_log WHERE user_id = ? ORDER BY timestamp ASC', [101]);\n    console.log('\\nFull audit history for user 101:');\n    history.forEach(entry => console.log(entry));\n\n  } catch (err) {\n    console.error('Database operation failed:', err);\n  } finally {\n    if (client.connected) {\n      await client.end();\n      console.log('Connection closed.');\n    }\n  }\n}\n\nrunImmutableExample();","lang":"javascript","description":"This quickstart demonstrates connecting to a MariaDB/MySQL database and performing append-only operations using the async/await pattern, illustrating how to implement an 'immutable' log for user actions rather than in-place updates."},"warnings":[{"fix":"Migrate to the official and actively maintained `@mariadb/mariadb-connector-nodejs` (npm `mariadb`) for all new and existing projects.","message":"This package relies on the `mariasql` library, which was last updated in April 2016 and is no longer maintained. It has known vulnerabilities and lacks support for modern database features or Node.js versions.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Avoid using this package. If absolutely necessary for legacy systems, ensure it runs on Node.js versions compatible with its dependencies, ideally within the 7.x-10.x range. Isolate it in containerized environments.","message":"The package officially requires Node.js v7.6.0 or greater. Running it on modern Node.js versions (e.g., Node.js 16+) may encounter compatibility issues, unexpected behavior, or errors due to breaking changes in Node.js core or underlying dependencies.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Understand that 'immutability' must be carefully designed and enforced at the application level through careful schema design (e.g., audit logs, versioning tables) and application logic. Do not expect tamper-proof cryptographic guarantees from the database driver itself. Consider dedicated immutable databases if strong guarantees are needed.","message":"Despite 'immutable' in its name, this package does not provide native immutable database features. It is a driver for MariaDB/MySQL (mutable by default) and facilitates an application-level immutable pattern (e.g., append-only logs) rather than enforcing cryptographic immutability like dedicated immutable databases (e.g., immudb, Dolt).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Replace `immutable-database-mariasql` with a modern, actively maintained database connector like `@mariadb/mariadb-connector-nodejs` (npm `mariadb`).","message":"The `immutable-database-mariasql` package itself is considered abandoned due to the deprecation of its core `mariasql` dependency and lack of recent updates or maintenance. It poses security risks and functional limitations for modern applications.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure `new Client()` is used and refer to the specific API of `immutable-database-mariasql` if it deviates from standard `mariasql` connection methods. The original `mariasql` uses `client.connect()` with a callback, or implicitly connects on query if auto-connect is enabled.","cause":"The `Client` instance was not properly initialized or the method name is incorrect for the version/wrapper.","error":"TypeError: client.connect is not a function"},{"fix":"Check network connectivity to the database server. Ensure the database server is running and accessible. Verify firewall rules. Consider upgrading or downgrading Node.js and/or the database server version to find a compatible combination if sticking with this legacy driver.","cause":"This error often indicates issues with the MariaDB/MySQL server connection, network instability, or protocol mismatches, especially with older drivers on newer servers or vice versa.","error":"Error: Packets out of order. Got: X Expected: Y"},{"fix":"Run `npm install mariasql` alongside `npm install immutable-database-mariasql` if `mariasql` is a peer dependency or not properly declared in the wrapper's `package.json`. It's safer to avoid this package entirely and use a modern driver.","cause":"The underlying `mariasql` package, which `immutable-database-mariasql` depends on, is not installed.","error":"Error: Cannot find module 'mariasql'"}],"ecosystem":"npm"}