Thank you!!! I just finished!!
SQL - Module for working with SQL databases
-
Please see this video for screen recording
-
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.csvhere is a sample project file from the video
--> AAA_new_bot_template.xmlTest 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 -
@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 x64did 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.
-
[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 successfullyMessages: 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'
-
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 successfullythe 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
-
[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.
-
@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 itfor 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.
-
I tried to setup an "ON DUPLICATE KEY UPDATE
id=id" clause to avoid errors during insert values that could cause an "duplicate key entry exception" but it seems that this clause is ignored in the "Insert single record" cube of the module?Always getting an SequelizeUniqueConstraintError: Validation error.



