1.0.4 • Published 3 years ago

sql-fixtures v1.0.4

Weekly downloads
1,916
License
MIT
Repository
github
Last release
3 years ago

sql-fixtures

Easily generate data that gets saved in the database, with foreign key dependencies automatically resolved. Ideal for integration tests and generating dummy data. Uses knex internally.

dormant but stable

sql-fixtures is not actively being worked on anymore, because it's pretty much done. I will still support it if any issues arise.

Supported Databases

DatabaseWorks?As of versionIntegration Tests?Usage
PostgresYes0.0.0Yesseveral projects known
MySQLYes*0.4.0Yesseveral projects known
sqlite3Yes*0.3.0Yesone known project
MariaDBYes**0.7.0Yesno known projects :(

*For MySQL and Maria you can run into issues for tables that lack a singular primary key.

**For sqlite, you can hit the same issue as MySQL and Maria above if you create your tables using "without rowid"

Install

npm install sql-fixtures

Simple Example

var sqlFixtures = require('sql-fixtures');

// depending on which database engine you are using
// this is a typical PostgreSQL config for the pg driver
var dbConfig = {
  client: 'pg',
  connection: {
    host: 'localhost',
    user: 'testdb',
    password: 'password',
    database: 'testdb',
    port: 15432
  }
};

var dataSpec = {
  users: {
    username: 'Bob',
    email: 'bob@example.com'
  }
};

sqlFixtures.create(dbConfig, dataSpec, function(err, result) {
  // at this point a row has been added to the users table
  console.log(result.users[0].username);
});

Documentation and Examples

Are available at the sql-fixtures website

Contributing

NOTE: I am hesitant to add more features at this point. I feel sql-fixtures is feature complete now and I want to keep it a small, focused module. If you have an idea for a feature you want to implement, please contact me first.

Please fork and send pull requests in the typical fashion.

There are both unit and integration tests. The unit tests are invoked with gulp test:unit.

Checkout integration_tests.md for the scoop on the integration tests.

2.0.0-beta.0

3 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

8 years ago

0.13.0

8 years ago

0.12.0

8 years ago

0.11.0

9 years ago

0.10.2

9 years ago

0.10.1

9 years ago

0.10.0

9 years ago

0.9.0

9 years ago

0.8.3

9 years ago

0.8.2

9 years ago

0.8.1

9 years ago

0.8.0

9 years ago

0.7.0

9 years ago

0.6.0

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.2

9 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.10

10 years ago

0.1.9

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago