Can I run an HTTP GET directly in SQL under MySQL?

BCS picture BCS · Nov 14, 2008 · Viewed 11.8k times · Source

I'd love to do this:

UPDATE table SET blobCol = HTTPGET(urlCol) WHERE whatever LIMIT n;

Is there code available to do this? I known this should be possible as the MySQL Docs include an example of adding a function that does a DNS lookup.

MySQL / windows / Preferably without having to compile stuff, but I can.

(If you haven't heard of anything like this but you would expect that you would have if it did exist, A "proly not" would be nice.)

EDIT: I known this would open a whole can-o-worms re security, however in my cases, the only access to the DB is via the mysql console app. Its is not a world accessible system. It is not a web back end. It is only a local data logging system

Answer

bobince picture bobince · Nov 15, 2008

No, thank goodness — it would be a security horror. Every SQL injection hole in an application could be leveraged to start spamming connections to attack other sites.

You could, I suppose, write it in C and compile it as a UDF. But I don't think it really gets you anything in comparison to just SELECTing in your application layer and looping over the results doing HTTP GETs and UPDATEing. If we're talking about making HTTP connections, the extra efficiency of doing it in the database layer will be completely dwarfed by the network delays anyway.