All connection attempts with `@` in password end in "address could not be resolved"
jwoehr opened this issue · 2 comments
jwoehr commented
>>> import sqlalchemy as sa
>>> engine = sa.create_engine('ibmi://JWOEHR:password@pub400.com')
>>> cnxn = engine.connect()
Traceback (most recent call last):
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3371, in _wrap_pool_connect
return fn()
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect
return _ConnectionFairy._checkout(self)
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout
rec = pool._do_get()
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get
with util.safe_reraise():
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
compat.raise_(
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
raise exception
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
return self._create_connection()
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection
return _ConnectionRecord(self)
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__
self.__connect()
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect
with util.safe_reraise():
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
compat.raise_(
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
raise exception
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect
self.dbapi_connection = connection = pool._invoke_creator(self)
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 574, in connect
return dialect.connect(*cargs, **cparams)
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect
return self.dbapi.connect(*cargs, **cparams)
pyodbc.OperationalError: ('08S01', '[08S01] [IBM][System i Access ODBC Driver]Communication link failure. comm rc=11001 - CWBCO1004 - Remote address could not be resolved (11001) (SQLDriverConnect)')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3325, in connect
return self._connection_cls(self, close_with_result=close_with_result)
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 96, in __init__
else engine.raw_connection()
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3404, in raw_connection
return self._wrap_pool_connect(self.pool.connect, _connection)
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3374, in _wrap_pool_connect
Connection._handle_dbapi_exception_noconnection(
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2208, in _handle_dbapi_exception_noconnection
util.raise_(
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
raise exception
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3371, in _wrap_pool_connect
return fn()
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect
return _ConnectionFairy._checkout(self)
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout
rec = pool._do_get()
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get
with util.safe_reraise():
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
compat.raise_(
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
raise exception
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
return self._create_connection()
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection
return _ConnectionRecord(self)
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__
self.__connect()
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect
with util.safe_reraise():
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
compat.raise_(
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
raise exception
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect
self.dbapi_connection = connection = pool._invoke_creator(self)
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 574, in connect
return dialect.connect(*cargs, **cparams)
File "/home/jwoehr/work/Apache/superset_venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect
return self.dbapi.connect(*cargs, **cparams)
sqlalchemy.exc.OperationalError: (pyodbc.OperationalError) ('08S01', '[08S01] [IBM][System i Access ODBC Driver]Communication link failure. comm rc=11001 - CWBCO1004 - Remote address could not be resolved (11001) (SQLDriverConnect)')
(Background on this error at: https://sqlalche.me/e/14/e3q8)
jwoehr commented
It's an @
in the password. Changed password, no problem. Tried encoding password with urllib.parse.quote_plus()
but no luck with that.
jwoehr commented
@kadler provided a solution that works:
import sqlalchemy as sa
import urllib.parse
user = 'user'
password = 'p@ssword'
password = urllib.parse.quote_plus(password)
engine_string = f'ibmi://{user}:{password}@ibmi.example.com'
print(engine_string)
try:
engine = sa.create_engine(engine_string)
cnxn = engine.connect()
except Exception as e:
print(e)
exit()
print('success!')