Not able to use urllib.urlopen

Padawan

Hi,

I am taking Exasol Advanced Analytics course and struggling with below error

SQL Error [22002]: VM error: IOError: [Errno socket error] [Errno -3] Temporary failure in name resolution (Session: 1669598356062630871)

Below is my python script which works fine when I ran it in Python console

CREATE OR REPLACE PYTHON SCALAR SCRIPT eur_to_usd(priceval DECIMAL(18,2)) RETURNS DECIMAL(18,2) AS
import urllib
import json
s = urllib.urlopen('https://free.currconv.com/api/v7/convert?q=EUR_USD&compact=ultra&apiKey=2e3983a73cac34f7c737').read()
data = json.loads(s)
def run(ctx):
return ctx.priceval * decimal.Decimal(data['EUR_USD'])
/

select fruits.*,eur_to_usd(price) from fruits

I have installed Python 3.8.3 on my system where few modification required to make this script work like "import urllib.request" instead of "import urllib". I am using Exasol community edition on Virtual Box. Even after restarting the virtual box did not resolve the issue. Kindly assist.

1 ACCEPTED SOLUTION

Moderator
Moderator

Hi,

that's likely a network issue. Check that first as described here https://community.exasol.com/t5/training-forum/enable-network-access-from-community-edition-in-virtu...

Best regards

Uwe

View solution in original post

2 REPLIES 2

Moderator
Moderator

Hi,

that's likely a network issue. Check that first as described here https://community.exasol.com/t5/training-forum/enable-network-access-from-community-edition-in-virtu...

Best regards

Uwe

View solution in original post

Padawan

Thanks Uwe for quick response.

Since https://free.currconv.com/api/v7/convert?q=EUR_USD&compact=ultra&apiKey=2e3983a73cac34f7c737 is currently down, I have tested the code with another API https://api.exchangeratesapi.io/latest and it worked like charm.

Thanks once again for your help in this.

Regards,

Manoj Gawde.