Registry / testing / fantasy-database

fantasy-database

JSON →
library2.0.1jsnpmunverified

A small SQLite database (with MySQL-compatible schema and seed data) containing fantasy books for testing query builders, ORMs, REST frameworks, etc. Version 2.0.1 is the latest stable release. This package is primarily used as a test fixture: it provides a pre-built SQLite database file (fantasy.db) and reference schema.sql + data.json for cross-language testing. Key differentiator: it offers a simple, consistent dataset for integration tests across multiple languages (Node, Python, etc.) without requiring a full database server.

npm install fantasy-database
INSTALL
IMPORT
SIG · FANTASY-DATABASE
F
fantasy-database
testingjavascriptv2.0.1
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.

fantasy.db
import path from 'path'; const dbPath = path.dirname(require.resolve('fantasy-database')) + '/fantasy.db';
The package does not export JavaScript symbols; you copy or reference the SQLite file directly.

Connects to the bundled SQLite database using Sequelize and runs a simple SELECT query.

const fs = require('fs'); const path = require('path'); const { Sequelize } = require('sequelize'); // Find the pre-built database file const dbPath = path.dirname(require.resolve('fantasy-database')) + '/fantasy.db'; const sequelize = new Sequelize({ dialect: 'sqlite', storage: dbPath, logging: false }); async function testQuery() { const [results] = await sequelize.query('SELECT * FROM books LIMIT 5'); console.log(results); await sequelize.close(); } testQuery().catch(console.error);
Debug
Known issues
gotchaThe database file is checked into Git and may become stale or cause merge conflicts.
fix
Regenerate the database by running 'npm start' after installation, or use schema.sql and data.json to build your own.
affects: >=1.0.0
gotchaThe schema uses MySQL-compatible syntax (e.g., AUTO_INCREMENT) but the database is SQLite. Some SQLite features may not match MySQL.
fix
Refer to schema.sql for SQLite-compatible DDL; note that auto-increment is handled via INTEGER PRIMARY KEY in SQLite.
affects: >=1.0.0
gotchaThere are no npm lifecycle scripts to automatically rebuild the database; you must manually copy the .db file or run the start script.
fix
Copy fantasy.db from node_modules/fantasy-database to your test fixtures, or execute 'npm run start' (if using as a project dependency, use scripts in your own package.json).
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'fantasy-database'
The package is not installed or is missing from node_modules.
fix
Run 'npm install fantasy-database --save-dev' (or --save) to add it as a dependency.
SQLITE_ERROR: no such table: books
The database file (fantasy.db) is not being pointed to correctly, or the database hasn't been built.
fix
Ensure you are using the correct path to fantasy.db (use require.resolve to locate it) or rebuild the database by executing 'npm start' in the package directory.
Error: Database file not found
The path to fantasy.db is incorrect.
fix
Use path.join(__dirname, 'node_modules', 'fantasy-database', 'fantasy.db') or rely on require.resolve to get the absolute path.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
fantasy-database — npm install fantasy-database · libregistry