-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
base: main
Are you sure you want to change the base?
fix: Asynchronous connection error when using databases other than Postgres or SQLite #5555
Conversation
…stgres or SQLite.
CodSpeed Performance ReportMerging #5555 will degrade performances by 58.3%Comparing Summary
Benchmarks breakdown
|
Does it work ? I think to use |
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 tried this solution . it doesn't work. this Exception is still raised. sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place? (Background on this error at: https://sqlalche.me/e/20/xd2s)
|
OK! What did you put in the environment variables: LANGFLOW DATABASE_URL and LANGFLOW_DATABASE_DRIVER_ASYNC? Have you tested with my branch? |
I tried it on Windows 11 . I installed the langflow 1.1.1 and then I merge your code in it . Then I run it with this command: python -m langflow run --env-file=.env in the
|
I fixed it. the engine |
Yes! That's why I asked you for both configurations, because one must use mysql+pymysql (For the non-asynchronous engine) and mysql+aiomysql (For the asynchronous engine). In your case the configuration would be like this: LANGFLOW_DATABASE_DRIVER_ASYNC=mysql+aiomysql |
"postgresql+psycopg://" | ||
if url_components[0].startswith("postgresql") | ||
else f"{self.database_driver_async}://" | ||
if self.database_driver_async |
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.
If provided, database_driver_async
should probably be the first choice.
"""Database driver async.""" | ||
database_driver_async: str | None = None | ||
"""Database URL for Langflow. If not provided, Langflow will use a SQLite database.""" |
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.
Param description should be switched.
Co-authored-by: Christophe Bornet <cbornet@hotmail.com>
Co-authored-by: Christophe Bornet <cbornet@hotmail.com>
OK, Thank you for your help ! I understand it. |
the engine problem is solved. there is another problem . sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1170, "BLOB/TEXT column 'description' used in key specification without a key length")
[SQL: CREATE INDEX ix_flow_description ON flow (description)] I fixed it in from sqlalchemy.sql.expression import text then change the code in line 116: batch_op.create_index(batch_op.f("ix_flow_description"), ["description"], unique=False) the modified code batch_op.create_index(batch_op.f("ix_flow_description"),[text("description(10)")], unique=False) I specified a length for the |
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:
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: