Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including knex with all npm packages installed. Try it out:

require('sqlite3'); const Knex = require('knex'); const knexSqlite = Knex({ client: 'sqlite', connection: ':memory:', }); // eslint-disable-next-line no-unused-vars const knexMysql = Knex({ client: 'mysql2', }); const knexPg = Knex({ client: 'pg', }); (async function run() { await knexSqlite.schema.createTable('test', (t) => { t.increments('id').primary(); t.string('data'); }); await knexSqlite('test').insert([{ data: 'foo' }, { data: 'bar' }]); console.log('test table data:', await knexSqlite('test')); console.log( knexPg({ f: 'foo', b: 'bar' }) .select('foo.*') .where('f.name', knexPg.raw('??', ['b.name'])) .whereIn('something', knexPg('bar').select('id')) .toSQL().sql ); })();

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

knex v3.0.1

A batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free