'How to insert data into a database from a telegram bot?

I'm writing a telegram bot. This bot is needed for testing. The main task of the bot is to write user responses to the database. I need to write a message from the user to the database. I can't write the message at this time because an error occurs. Where did I go wrong? Please help solve this problem.

      if (msg.text === '/start') {
        await bot.sendMessage(msg.chat.id, "message", {
          reply_markup: {
            keyboard: [
              ['Start the test']
            ]
          }
        })
      }
      else if (msg.text === 'Start the test') {
        await bot.sendMessage(msg.chat.id, "Please enter your name")      
          bot.on('message', async msg => {
            const name = msg.text
            const insert = `INSERT INTO User (username) VALUE ('${name}')`
            await sequelize.query(insert)
          })
      }

ERROR MESSAGE:

Executing (default): INSERT INTO User (username) VALUE ('name')
node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

Error
    at Query.run (/home/user/bot/node_modules/sequelize/dist/lib/dialects/postgres/query.js:50:25)
    at /home/user/bot/node_modules/sequelize/dist/lib/sequelize.js:313:28
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async TelegramBot.<anonymous> (/home/user/bot/bot.js:60:13) {
  name: 'SequelizeDatabaseError',
  parent: error: syntax error at or near "VALUE"
      at Parser.parseErrorMessage (/home/user/bot/node_modules/pg-protocol/dist/parser.js:287:98)
      at Parser.handlePacket (/home/user/bot/node_modules/pg-protocol/dist/parser.js:126:29)
      at Parser.parse (/home/user/bot/node_modules/pg-protocol/dist/parser.js:39:38)
      at Socket.<anonymous> (/home/user/bot/node_modules/pg-protocol/dist/index.js:11:42)
      at Socket.emit (node:events:390:28)
      at addChunk (node:internal/streams/readable:315:12)
      at readableAddChunk (node:internal/streams/readable:289:9)
      at Socket.Readable.push (node:internal/streams/readable:228:10)
      at TCP.onStreamRead (node:internal/stream_base_commons:199:23) {
    length: 94,
    severity: 'ERROR',
    code: '42601',
    detail: undefined,
    hint: undefined,
    position: '28',
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: undefined,
    table: undefined,
    column: undefined,
    dataType: undefined,
    constraint: undefined,
    file: 'scan.l',
    line: '1145',
    routine: 'scanner_yyerror',
    sql: "INSERT INTO User (username) VALUE ('name')",
    parameters: undefined
  },
  original: error: syntax error at or near "VALUE"
      at Parser.parseErrorMessage (/home/user/bot/node_modules/pg-protocol/dist/parser.js:287:98)
      at Parser.handlePacket (/home/user/bot/node_modules/pg-protocol/dist/parser.js:126:29)
      at Parser.parse (/home/user/bot/node_modules/pg-protocol/dist/parser.js:39:38)
      at Socket.<anonymous> (/home/user/bot/node_modules/pg-protocol/dist/index.js:11:42)
      at Socket.emit (node:events:390:28)
      at addChunk (node:internal/streams/readable:315:12)
      at readableAddChunk (node:internal/streams/readable:289:9)
      at Socket.Readable.push (node:internal/streams/readable:228:10)
      at TCP.onStreamRead (node:internal/stream_base_commons:199:23) {
    length: 94,
    severity: 'ERROR',
    code: '42601',
    detail: undefined,
    hint: undefined,
    position: '28',
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: undefined,
    table: undefined,
    column: undefined,
    dataType: undefined,
    constraint: undefined,
    file: 'scan.l',
    line: '1145',
    routine: 'scanner_yyerror',
    sql: "INSERT INTO User (username) VALUE ('text')",
    parameters: undefined
  },
  sql: "INSERT INTO User (username) VALUE ('text')",
  parameters: {}
}
[nodemon] app crashed - waiting for file changes before starting...


Solution 1:[1]

You have to change your query from:

INSERT INTO User (username) VALUE ('text')

to

INSERT INTO User (username) VALUES ('text')

VALUE -> VALUES

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ali Padida