How to insert table with knex

Hello guys,

How I can Insert a new table with knex on a sqlite database:
I have modify this tutorial:
To insert a new table on a sqlite database.

I’m using an action but it’s not working.

function action(bp: typeof sdk, event: sdk.IO.IncomingEvent, args: any, { user, temp, session } = event.state) {
  /** Your code starts below */

   * This utility can Save/Retrieve/Update data to MySQL DB
   * @title User MySQL DB Utility
   * @category Utility
   * @author Abhishek Raj Simon
   * @param {string} name - Only supports get/set/update operations
   * @param {string} table - Table name
   * @param {string} key - Can contain any key against which value needs to be pushed to DB
   * @param {string} value - Can contain a any value that needs to be pushed to DB
  const userDBUtility = async () => {
    const knex = require('knex')({
      client: 'sqlite3',
      connection: {
        filename: './sys.sqlite3'
      useNullAsDefault: false,
      log: {
        warn(message) {
        error(message) {
        deprecate(message) {
        debug(message) {


    console.log('je suis ici -------------')

    /* Inserer la table coco dans la BDD nommer sys*/
    knex.schema.createTable('coco', function(table) {

  return userDBUtility()

  /** Your code ends here */

I have no clue, no warning , no error message. Nothing happen
Could you help me please.

You might want to check an example in the source code itself to see how we do it, using createTableIfNotExists, and no schema:

I see you’re using the example in the knex documentation! Hopefully someone else has some experience with this and could help us out.


Thanks to my Quebecois friend

1 Like