Skip to content
A knex.js session store for express-session, supporting PostgreSQL, MySQL, MariaDB, Oracle and SQLite.
Branch: master
Clone or download
Pull request Compare This branch is 213 commits ahead, 53 commits behind rawberg:master.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig Editorconfig Jan 27, 2016
.travis.yml Travis test node 4, 6, and 7 Feb 8, 2017
LICENSE ISC License Dec 6, 2014 Add example application May 13, 2015 Added Oracle as a supported DB in the file and fixed a comm… Sep 15, 2017
example-postgres.js tab indent Sep 9, 2015
example.js correct maxAge seconds description (#45) Feb 18, 2019
index.js added stopDbCleanup (#47) Feb 18, 2019
package.json Bump deps Nov 17, 2017
test.js Implement touch Jan 27, 2016
yarn.lock Oracle support + yarn Oct 28, 2016

Connect Session Knex

NPM Version NPM Downloads Node.js Version Build Status Dependency Status Coverage Status


connect-session-knex is an express-session store backed by PostgreSQL, MySQL, MariaDB, MSSQL, Oracle or SQLite3, via the knex.js library.


$ npm install connect-session-knex


Example application using the defaults

Example application with PostgreSQL

With Express 3 or Connect


  • tablename='sessions' Tablename to use. Defaults to 'sessions'.
  • sidfieldname='sid' Field name in table to use for storing session ids. Defaults to 'sid'.
  • knex knex instance to use. Defaults to a new knex instance, using sqlite3 with a file named 'connect-session-knex.sqlite'
  • createtable if the table for sessions should be created automatically or not.
  • clearInterval milliseconds between clearing expired sessions. Defaults to 60000.

If the table does not exist in the schema, this module will attempt to create it unless the 'createtable' option is false.

If a knex instance is not provided, this module will attempt to create a sqlite3 database, with a file named 'connect-session-knex.sqlite', in the working directory of the process.


PostgreSQL or SQLite

Table Name "sessions"

Column Type Modifiers Storage
sid character varying(255) not null extended
sess json not null extended
expired timestamp with time zone not null plain


    "sessions_pkey" PRIMARY KEY, btree (sid)  
    "sessions_expired_index" btree (expired)


You can’t perform that action at this time.