-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: the database url is missing ":\\" when sqlite or postgresql is not used #5492
base: main
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #5492 will degrade performances by 23.93%Comparing Summary
Benchmarks breakdown
|
Copilot
AI
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
@@ -93,7 +93,9 @@ def _create_engine(self) -> AsyncEngine: | |||
"pool_size": self.settings_service.settings.pool_size, | |||
"max_overflow": self.settings_service.settings.max_overflow, | |||
} | |||
database_url = "postgresql+psycopg://" if url_components[0].startswith("postgresql") else url_components[0] | |||
database_url = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code should check if '://' is already present in the URL before appending it to avoid creating an invalid URL.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @qq745639151
Good catch. Please take a look at my comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about something like this:
def _create_engine(self) -> AsyncEngine:
"""Create the engine for the database."""
url_components = self.database_url.split("://", maxsplit=1)
if url_components[0].startswith("sqlite"):
scheme = "sqlite+aiosqlite"
kwargs = {}
else:
kwargs = {
"pool_size": self.settings_service.settings.pool_size,
"max_overflow": self.settings_service.settings.max_overflow,
}
scheme = "postgresql+psycopg" if url_components[0].startswith("postgresql") else url_components[0]
database_url = f"{scheme}://{url_components[1]}"
return create_async_engine(
database_url,
connect_args=self._get_connect_args(),
**kwargs,
)
If I set the environment varialbe
LANGFLOW_DATABASE_URL
start with "mysql+aiomysql://", the function_create_engine
split it to judge the database will be used. But if sqlite or postgresql is not used. the url is missing "://"