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: SQLDatabase has no attribute set_event_manager #4192

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,33 @@
from sqlalchemy import create_engine
from sqlalchemy.pool import StaticPool

from langflow.custom import CustomComponent
from langflow.custom import Component
from langflow.io import (
Output,
StrInput,
)


class SQLDatabaseComponent(CustomComponent):
class SQLDatabaseComponent(Component):
display_name = "SQLDatabase"
description = "SQL Database"
name = "SQLDatabase"

def build_config(self):
return {
"uri": {"display_name": "URI", "info": "URI to the database."},
}
inputs = [
StrInput(name="uri", display_name="URI", info="URI to the database.", required=True),
]

outputs = [
Output(display_name="SQLDatabase", name="SQLDatabase", method="build_sqldatabase"),
]

def clean_up_uri(self, uri: str) -> str:
if uri.startswith("postgres://"):
uri = uri.replace("postgres://", "postgresql://")
return uri.strip()

def build(self, uri: str) -> SQLDatabase:
uri = self.clean_up_uri(uri)
def build_sqldatabase(self) -> SQLDatabase:
uri = self.clean_up_uri(self.uri)
# Create an engine using SQLAlchemy with StaticPool
engine = create_engine(uri, poolclass=StaticPool)
return SQLDatabase(engine)
Loading