Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

You have an error in your SQL syntax when using docker exec rest api

I try to run a mysql statement via docker exec api -> https://docs.docker.com/engine/api/v1.41/#operation/ContainerExec

My Statement looks like this

{
    "AttachStdin": false,
    "AttachStdout": true,
    "AttachStderr": true,
    "DetachKeys": "ctrl-p,ctrl-q",
    "Tty": false,
    "Cmd": [
        "bin/bash","-c", "mysql -uroot -ptesttest -e 'INSERT INTO `mandator_1`.`terminal` (`serialNumber`, `name`, `isActive`, `status`, `profileId`, `businessId`, `divisionId`, `ipAddress`, `groupId`, `setupVersion`, `macAddress`, `authType`) VALUES ('54321', '54321', '1', NULL, '1', '1', NULL, '172.45.17.197', '1', NULL, 'E4-F1-D3-FD', '2');' mandator_1"
    ]
}

but when i run the statement i get an error

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘.17.197, 1, NULL, E4-F1-D3-FD, 2)’ at line 1

i think my escaping is wrong but at which point?

>Solution :

Try to change quote by double quote:

VALUES (\"54321\", \"54321\", \"1\", ...., \"2\");
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading