SQL - Module for working with SQL databases

Share BAS modules
  • problem is NOT the DB. promised

    3 examples:

    1. bot with nodejs mysql2 function
    can run 2000 writes per second no problem. no errors
    all values are corrrectly inserted
    insert into log (id,timestamp,botname,comment) values ([[ID]],CURRENT_TIMESTAMP,[[BOTNAME]],[[COMMENT]]);
    --> insert into log (id,timestamp,botname,comment) values (123,CURRENT_TIMESTAMP,'test','test');

    2. Bot with your SQL and "Execute query" function
    can run 2000 writes per second no problem. no errors
    all values are corrrectly inserted
    insert into log (id,timestamp,botname,comment) values ([[ID]],CURRENT_TIMESTAMP,[[BOTNAME]],[[COMMENT]]);
    --> insert into log (id,timestamp,botname,comment) values (123,CURRENT_TIMESTAMP,'test','test');

    3. Bot with your SQL and "Insert Row" function
    First run after new start:
    insert into log (id,timestamp,botname,comment) values ([[ID]],CURRENT_TIMESTAMP,[[BOTNAME]],[[COMMENT]]);
    --> insert into log (id,timestamp,botname,comment) values (NULL,NULL,NULL,NULL);
    NO VALUES !!!!!

    4. Bot with your SQL and "Insert Row" function
    second run, can run 2000 writes per second no problem. no errors
    insert into log (id,timestamp,botname,comment) values ([[ID]],CURRENT_TIMESTAMP,[[BOTNAME]],[[COMMENT]]);
    --> insert into log (id,timestamp,botname,comment) values (123,CURRENT_TIMESTAMP,'test','test');
    all values are corrrectly inserted

    it is always ONLY on 1. run

    is there something i can check locally? DB connection is fine and everything else works fine as well, just not sequelize

  • @tecnewb, attach a screenshot of your settings in the "Insert Row" action

  • @GhostZ

    this is execute query

    Bildschirmfoto 2021-05-03 um 17.55.20.png

    and this is insert query

    Bildschirmfoto 2021-05-03 um 18.38.39.png

  • Please see this video for screen recording

    https://streamable.com/11eo16

  • @tecnewb, attach a project, a file with test data and a table schema, I will try to repeat the error.

  • @GhostZ

    Table:

    CREATE TABLE `z_log` (
      `action_id` int NOT NULL AUTO_INCREMENT,
      `time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
      `error` tinyint(1) NOT NULL DEFAULT '0',
      `vm_id` int NOT NULL,
      `run_id` varchar(45) NOT NULL,
      `botname` varchar(45) NOT NULL,
      `message` varchar(500) NOT NULL,
      PRIMARY KEY (`action_id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=467 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
    
    

    This file has to be put in "C:/Sync/vm.csv" it contains the settings for the bot: VM_ID, DB Host IP ([[DB_IP]]), DB User, DB Password
    Variable "ACC_ID" is not set in the file but also not used in the script
    Please note this file is TAB Seperated and that the DB Name is hardcoded in the "DB Setup" Function in "start"
    --> vm.csv

    here is a sample project file from the video
    --> AAA_new_bot_template.xml

    Test Data to be inserted to DB is generated live by the script

    Funny sidenote:
    when the "Insert records" is in the "Main" function, then "execute query" fails with the error of empty VM_ID
    when you delete "insert records" everything works
    this happens only AFTER "Insert records" is triggered
    --> https://streamable.com/k77vu6

  • @tecnewb, Checked I do not have this error
    997ec414-47e4-4e8e-ad9a-07b67d709f38-image.png

    But I saw this in the settings of your project, perhaps these settings will cause a conflict, try disabling all modules and Node.js itself

    2a7952f4-46d3-470d-9422-019faf5e99c0-image.png

  • @GhostZ okay i disabled the modules and nodejs, but it is still the same
    but when it is not there for you, do you have any additional runtimes/libraries installed on your PC?
    On my VM i only installed Visual C++ redist 2019 x64

    did you use mysql or sqlite?
    maybe sequelize mysql implementation is just broken

  • @tecnewb, Sqlite, but it doesn't matter which dialect is used, because the module itself works with all dialects in the same way, and if there was an error in the module, it would be with any dialect. If the error is repeated with Node.js 8.6.0 disabled, then most likely the error is really in the sequelize implementation. But I previously checked all actions with mysql and there were no errors. Check if you have an error with this project SQLtester.xml.

  • @GhostZ

    [424058906] [22:28:30] Thread #1 : Executing (default): SELECT 1+1 AS result
    [424058906] [22:28:30] Thread #1 : Executing (default): SELECT 2+3 AS result
    [424058906] [22:28:30] Thread #1 : Result: [{"result":5}]
    [424058906] [22:28:30] Thread #1 : Executing (default): SELECT 1+1 AS result
    [989962290] [22:28:31] Thread #1 : Query | Function completed successfully
    [66240405] [22:28:31] Thread #1 : Executing (default): DROP TABLE IF EXISTS CountRecords
    [953171962] [22:28:31] Thread #1 : CountRecords | An error occured (66240405): SequelizeDatabaseError: DROP command denied to user 'bot'@'10.0.0.143' for table 'CountRecords'
    [66240405] [22:28:32] Thread #1 : Executing (default): DROP TABLE IF EXISTS InsertRecords_SelectRecords
    [953171962] [22:28:32] Thread #1 : InsertRecords_SelectRecords | An error occured (66240405): SequelizeDatabaseError: DROP command denied to user 'bot'@'10.0.0.143' for table 'InsertRecords_SelectRecords'
    [66240405] [22:28:33] Thread #1 : Executing (default): DROP TABLE IF EXISTS DeleteRecords
    [953171962] [22:28:33] Thread #1 : DeleteRecords | An error occured (66240405): SequelizeDatabaseError: DROP command denied to user 'bot'@'10.0.0.143' for table 'DeleteRecords'
    [66240405] [22:28:34] Thread #1 : Executing (default): DROP TABLE IF EXISTS UpdateRecords
    [953171962] [22:28:34] Thread #1 : UpdateRecords | An error occured (66240405): SequelizeDatabaseError: DROP command denied to user 'bot'@'10.0.0.143' for table 'UpdateRecords'
    [989962290] [22:28:35] Thread #1 : Close | Function completed successfully
    
    Messages:
           1 - SequelizeDatabaseError: DROP command denied to user 'bot'@'10.0.0.143' for table 'InsertRecords_SelectRecords'
           1 - SequelizeDatabaseError: DROP command denied to user 'bot'@'10.0.0.143' for table 'DeleteRecords'
           1 - SequelizeDatabaseError: DROP command denied to user 'bot'@'10.0.0.143' for table 'UpdateRecords'
           1 - SequelizeDatabaseError: DROP command denied to user 'bot'@'10.0.0.143' for table 'CountRecords'
    

    Bildschirmfoto 2021-05-03 um 22.31.19.png

  • @tecnewb, remove action 66240405

  • ok i created a new schema and gave it full rights
    this happened

    [424058906] [22:38:47] Thread #1 : Executing (default): SELECT 1+1 AS result
    [424058906] [22:38:47] Thread #1 : Executing (default): SELECT 2+3 AS result
    [424058906] [22:38:47] Thread #1 : Result: [{"result":5}]
    [424058906] [22:38:47] Thread #1 : Executing (default): SELECT 1+1 AS result
    [989962290] [22:38:47] Thread #1 : Query | Function completed successfully
    [66240405] [22:38:48] Thread #1 : Executing (default): DROP TABLE IF EXISTS CountRecords
    [66240405] [22:38:48] Thread #1 : Result: [{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1},{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1}]
    [683197981] [22:38:48] Thread #1 : Executing (default): CREATE TABLE IF NOT EXISTS CountRecords ( id INTEGER PRIMARY KEY, test TEXT NOT NULL );
    [683197981] [22:38:48] Thread #1 : Result: [{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":0},{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":0}]
    [560627700] [22:38:48] Thread #1 : Result: {"id":{"type":"INT","allowNull":false,"defaultValue":null,"primaryKey":true,"autoIncrement":false,"comment":null},"test":{"type":"TEXT","allowNull":false,"defaultValue":null,"primaryKey":false,"autoIncrement":false,"comment":null}}
    [953171962] [22:38:49] Thread #1 : CountRecords | An error occured (560627700): SequelizeDatabaseError: Invalid default value for 'id'
    [66240405] [22:38:49] Thread #1 : Executing (default): DROP TABLE IF EXISTS InsertRecords_SelectRecords
    [66240405] [22:38:49] Thread #1 : Result: [{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1},{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1}]
    [953171962] [22:38:49] Thread #1 : InsertRecords_SelectRecords | An error occured (66240405): SequelizeDatabaseError: Invalid default value for 'id'
    [66240405] [22:38:50] Thread #1 : Executing (default): DROP TABLE IF EXISTS DeleteRecords
    [66240405] [22:38:50] Thread #1 : Result: [{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1},{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1}]
    [953171962] [22:38:50] Thread #1 : DeleteRecords | An error occured (66240405): SequelizeDatabaseError: Invalid default value for 'id'
    [66240405] [22:38:51] Thread #1 : Executing (default): DROP TABLE IF EXISTS UpdateRecords
    [66240405] [22:38:51] Thread #1 : Result: [{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1},{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1}]
    [953171962] [22:38:51] Thread #1 : UpdateRecords | An error occured (66240405): SequelizeDatabaseError: Invalid default value for 'id'
    [989962290] [22:38:52] Thread #1 : Close | Function completed successfully
    

    the table in the DB is empty

  • Bro thanks for your time, but i will just use the Execute Query function.
    except you have a definitive clue now, i think the searching will be endless ;)
    it's not worth our both time as it could be anything somewhere in my server setup to windows to sequelize

  • @tecnewb, try this script again SQLtester.xml

  • @GhostZ

    [424058906] [23:14:15] Thread #1 : Executing (default): SELECT 1+1 AS result
    [424058906] [23:14:15] Thread #1 : Executing (default): SELECT 2+3 AS result
    [424058906] [23:14:15] Thread #1 : Result: [{"result":5}]
    [424058906] [23:14:15] Thread #1 : Executing (default): SELECT 1+1 AS result
    [989962290] [23:14:16] Thread #1 : Query | Function completed successfully
    [66240405] [23:14:16] Thread #1 : Executing (default): DROP TABLE IF EXISTS CountRecords
    [66240405] [23:14:16] Thread #1 : Result: [{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1},{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1}]
    [683197981] [23:14:16] Thread #1 : Executing (default): CREATE TABLE IF NOT EXISTS CountRecords ( id INTEGER PRIMARY KEY NOT NULL DEFAULT 0, test TEXT NOT NULL );
    [683197981] [23:14:16] Thread #1 : Result: [{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":0},{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":0}]
    [560627700] [23:14:17] Thread #1 : Result: {"id":{"type":"INT","allowNull":false,"defaultValue":"0","primaryKey":true,"autoIncrement":false,"comment":null},"test":{"type":"TEXT","allowNull":false,"defaultValue":null,"primaryKey":false,"autoIncrement":false,"comment":null}}
    [560627700] [23:14:17] Thread #1 : Executing (default): INSERT INTO `CountRecords` (`test`) VALUES ('test1'),('test2'),('test3'),('test21');
    [953171962] [23:14:17] Thread #1 : CountRecords | An error occured (560627700): SequelizeUniqueConstraintError: Validation error
    [66240405] [23:14:18] Thread #1 : Executing (default): DROP TABLE IF EXISTS InsertRecords_SelectRecords
    [66240405] [23:14:18] Thread #1 : Result: [{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1},{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1}]
    [954873799] [23:14:18] Thread #1 : Executing (default): CREATE TABLE IF NOT EXISTS InsertRecords_SelectRecords ( id INTEGER PRIMARY KEY NOT NULL DEFAULT 0, text TEXT NOT NULL, num INTEGER NOT NULL, active BOOLEAN NOT NULL, null_or_not TEXT );
    [954873799] [23:14:18] Thread #1 : Result: [{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":0},{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":0}]
    [355848310] [23:14:18] Thread #1 : Result: {"id":{"type":"INT","allowNull":false,"defaultValue":"0","primaryKey":true,"autoIncrement":false,"comment":null},"text":{"type":"TEXT","allowNull":false,"defaultValue":null,"primaryKey":false,"autoIncrement":false,"comment":null},"num":{"type":"INT","allowNull":false,"defaultValue":null,"primaryKey":false,"autoIncrement":false,"comment":null},"active":{"type":"TINYINT(1)","allowNull":false,"defaultValue":null,"primaryKey":false,"autoIncrement":false,"comment":null},"null_or_not":{"type":"TEXT","allowNull":true,"defaultValue":null,"primaryKey":false,"autoIncrement":false,"comment":null}}
    [953171962] [23:14:18] Thread #1 : InsertRecords_SelectRecords | An error occured (355848310): SequelizeDatabaseError: Invalid default value for 'num'
    [66240405] [23:14:19] Thread #1 : Executing (default): DROP TABLE IF EXISTS DeleteRecords
    [66240405] [23:14:19] Thread #1 : Result: [{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1},{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1}]
    [953171962] [23:14:19] Thread #1 : DeleteRecords | An error occured (66240405): SequelizeDatabaseError: Invalid default value for 'num'
    [66240405] [23:14:20] Thread #1 : Executing (default): DROP TABLE IF EXISTS UpdateRecords
    [66240405] [23:14:20] Thread #1 : Result: [{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1},{"fieldCount":0,"affectedRows":0,"insertId":0,"info":"","serverStatus":2,"warningStatus":1}]
    [953171962] [23:14:20] Thread #1 : UpdateRecords | An error occured (66240405): SequelizeDatabaseError: Invalid default value for 'num'
    [989962290] [23:14:21] Thread #1 : Close | Function completed successfully
    
  • @tecnewb, ok, I understood the reason for the "Invalid default value for" error, I fixed it in the test project, updated the project in the message above and now I will fix it in the module code and post the updated version. But the reason for the "can not be empty" error is not yet known.

  • @tecnewb, updated the module, you can try now, but you need to install the new module as a custom one.

  • @GhostZ
    Oh that's great!
    "Invalid default value for 'xy'" is what i meant with the "can not be empty"

    so the search is NOT endless :D
    thanks, i will try it

    for my understanding:

    • i install updated version as Custom module
    • open installed custom module folder
    • copy all files there
    • go to SQL BAS (not custom) module folder
    • replace all files
    • delete custom module as it is updated in BAS now

    will that work so i don't have to change the finished bots?

  • @tecnewb, for details on installing modules, see the topic on improving the modular system, by the way, I just updated the module, so download it if you downloaded it earlier, removed the synchronization of the model, which should completely remove the unnecessary request to create a table by sequelize.

  • How would we insert data that has emoji's or special characters like this ⓐⓑⓒⓓⓔ

  • 0 Votes
    3 Posts
    1330 Views
  • 3 Votes
    24 Posts
    7123 Views
  • 2 Votes
    27 Posts
    4980 Views
  • 8 Votes
    34 Posts
    8879 Views
  • 7 Votes
    1 Posts
    1400 Views