a) changed socket.gethostbyname() to socket.getaddrinfo() to support IPv6 addresses
b) initial changes for some sqlalchemy support