Repository: PrefectHQ/prefect
Pull request: Make database parameter optional in ConnectionComponents  #15511
closes  https://github.com/PrefectHQ/prefect/issues/15511

Problem statement:
ConnectionComponents: Make database optional for proper connection string formation
### 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.

```py
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:
```py
ConnectionComponents(driver="oracle+oracledb", username="root", password="root", host="xx").create_url()
# output: oracle+oracledb://root:***@xx
```

### Version info (`prefect version` output)

```Text
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_

Hints from issue discussion:
hi @OUBVITOL - thanks for the issue!

would you be willing to contribute a PR for this?

Commit message: Make database optional in ConnectionComponents

Patch to review:
diff --git a/src/integrations/prefect-sqlalchemy/prefect_sqlalchemy/credentials.py b/src/integrations/prefect-sqlalchemy/prefect_sqlalchemy/credentials.py
index 0758d2eb6aaf..fe416a54145e 100644
--- a/src/integrations/prefect-sqlalchemy/prefect_sqlalchemy/credentials.py
+++ b/src/integrations/prefect-sqlalchemy/prefect_sqlalchemy/credentials.py
@@ -103,7 +103,9 @@ class ConnectionComponents(BaseModel):
     driver: Union[AsyncDriver, SyncDriver, str] = Field(
         default=..., description="The driver name to use."
     )
-    database: str = Field(default=..., description="The name of the database to use.")
+    database: Optional[str] = Field(
+        default=None description="The name of the database to use."
+    )
     username: Optional[str] = Field(
         default=None, description="The user name used to authenticate."
     )


Code review comments:
diff_hunk: @@ -103,7 +103,9 @@ class ConnectionComponents(BaseModel):
     driver: Union[AsyncDriver, SyncDriver, str] = Field(
         default=..., description="The driver name to use."
     )
-    database: str = Field(default=..., description="The name of the database to use.")
+    database: Optional[str] = Field(
+        default=None description="The name of the database to use."
path: src/integrations/prefect-sqlalchemy/prefect_sqlalchemy/credentials.py
text: @user1:
I think there will be some implications associated with this being  optional now
```suggestion
        default=None, description="The name of the database to use."
```