Making gethostbyaddr accessible in PostgreSQL via Python
CREATE PROCEDURAL LANGUAGE 'plpythonu'; | |
CREATE OR REPLACE FUNCTION gethostbyaddr(address text) | |
RETURNS text | |
LANGUAGE plpythonu | |
AS $$ | |
import socket | |
try: | |
return socket.gethostbyaddr(address)[1][0] | |
except: | |
return None | |
$$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment