Skip to content
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: Asynchronous connection error when using databases other than Postgres or SQLite #5555

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MarceloNunesAlves
Copy link
Contributor

This PR introduces a new environment variable, LANGFLOW_DATABASE_DRIVER_ASYNC, to specify the database driver used for asynchronous database connections. This allows for greater flexibility in supporting different database systems without requiring code changes.

Motivation:

Currently, asynchronous database connections were limited to Postgres and SQLite. This restriction made it difficult to use Langflow with other database systems.

Below is the error message:

Screenshot from 2025-01-06 11-09-10

Changes:

  • Added the LANGFLOW_DATABASE_DRIVER_ASYNC environment variable.

  • Updated the asynchronous connection logic to dynamically select the appropriate database driver based on the value of this environment variable.

  • Added error handling for unsupported database drivers.

Example:

To connect to a MySQL database asynchronously, set the environment variable as follows:

LANGFLOW_DATABASE_DRIVER_ASYNC=mysql+aiomysql

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Jan 6, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jan 6, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jan 6, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jan 6, 2025
@ogabrielluiz ogabrielluiz requested a review from cbornet January 6, 2025 17:52
Copy link

codspeed-hq bot commented Jan 6, 2025

CodSpeed Performance Report

Merging #5555 will degrade performances by 58.3%

Comparing MarceloNunesAlves:fix/db_async_driver (fc82703) with main (16ff8eb)

Summary

⚡ 1 improvements
❌ 2 regressions
✅ 12 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main MarceloNunesAlves:fix/db_async_driver Change
test_get_and_cache_all_types_dict 1 ms 2.5 ms -58.3%
test_successful_run_with_input_type_text 271.3 ms 208 ms +30.44%
test_successful_run_with_output_type_any 260.3 ms 294.5 ms -11.61%

@cbornet
Copy link
Collaborator

cbornet commented Jan 7, 2025

Does it work ? I think to use mysql+aiomysql, you need the aiomysql package to be installed which is not the case in the default LangFlow.

@MarceloNunesAlves
Copy link
Contributor Author

Does it work ? I think to use mysql+aiomysql, you need the aiomysql package to be installed which is not the case in the default LangFlow.

Yes! You need to install the driver of your choice. And I did it this way because it is generic for other DB, such as Oracle and SQLServer.
I think the idea of the project has always been to allow the use of any relational database. And frankly, the way this method works with these different conditional structures, I don't think it's the most appropriate. but I kept it so as not to harm others who already use this version in production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants