I have a weird problem that I don't have a good way around.
My company, because reasons, stores scripting code in a database table. Don't ask. Whenever I have to insert a new version of the code, I have to go through the file and manually backslash all the strings to be able to run it in my insert statement.
Is there a tool which will escape all of the strings in the file for me so that I can just copy and paste without having to do this manual work?
The file will likely contain single and double quotes as well as quotes within quotes, ie "this is \"weird\"".
Here's an example of the query I'm running:
delimiter $$
insert into table (code) values ("package a.b.c;
class SomeClass {
var thing = "so \"weird\" and thing's stuff"
}");
I don't need spaces escaped, nor semicolons, but anything that would break my quotes should be escaped. The contents of the thing variable would break my quoting in the example given above.
$$become\$\$? Should\"weird\"become\\\"weird\\\"?