PrefectHQ / prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://prefect.io
Apache License 2.0
15.95k stars 1.57k forks source link

ConnectionComponents: Make database optional for proper connection string formation #15511

Open OUBVITOL opened 3 days ago

OUBVITOL commented 3 days ago

Bug summary

In the ConnectionComponents class from prefect_sqlalchemy, the database parameter is mandatory and used instead of host when creating the connection URL. This leads to incorrect connection string generation. The database parameter should be made optional to allow proper connection string formation in all cases.

from prefect_sqlalchemy import ConnectionComponents

# Current behavior: Generates incorrect connection string
ConnectionComponents(driver="oracle+oracledb", username="root", password="root", database="xx").create_url()
# Output: oracle+oracledb://root:***@/xx

Proposed behavior: database is made optional, can specify host instead:

ConnectionComponents(driver="oracle+oracledb", username="root", password="root", host="xx").create_url()
# output: oracle+oracledb://root:***@xx

Version info (prefect version output)

Version:             3.0.3
API version:         0.8.4
Python version:      3.12.5
Git commit:          d9c51bc3
Built:               Fri, Sep 20, 2024 8:52 AM
OS/Arch:             win32/AMD64
Profile:             local
Server type:         server
Pydantic version:    2.9.2
Integrations:
  prefect-sqlalchemy: 0.5.1

Additional context

No response

zzstoatzz commented 2 days ago

hi @OUBVITOL - thanks for the issue!

would you be willing to contribute a PR for this?