Created
June 23, 2013 13:42
-
-
Save qerub/5845073 to your computer and use it in GitHub Desktop.
Making gethostbyaddr accessible in PostgreSQL via Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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