daneshpatel / sqlalchemy-jdbcapi

SQLAlchemy dialect for JDBC supported database. (Using JDBCAPI)
Other
23 stars 25 forks source link

jdbc url is wrongly parsed #11

Open fhrzn opened 1 year ago

fhrzn commented 1 year ago

Describe the bug In the pgjdbc.py there is a logic to parse sqlalchemy generated url to the one expected by jdbc. In the current implementation it causing the java.net.java.net.UnknownHostException error.

To Reproduce Steps to reproduce the behavior:

  1. Init sqlalchemy engine by putting standard sqlalchemy url or follow the given example
  2. Run the code
  3. See error

Expected behavior The expected behavior should be connected successfully to the database.

Screenshots

Screenshot 2023-03-12 at 01 38 29

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

fhrzn commented 1 year ago

For manual workaround just insert url as jdbc expected format. jdbc:postgresql://example.com:1521/db

Example in sqlalchemy: engine = create_engine(f'jdbcapi+pgjdbc://{uname}:{pwd}@{host}:{port}/{dbname}')

borgle commented 1 year ago

@henrykp If your "uname" or "pwd" contains special characters, use urllib quote like this:

from urllib.parse import quote
uname=quote("Amy#clusterid")
pwd=quote("secert@123")