getaddrbyhost in PostgreSQL

PostgreSQL does not ship with a function to do DNS lookups. Luckily, it is very easy to define new functions, with multiple language choices. Here’s how you can make gethostbyaddr accessible via Python: