Find answers from the community

Updated 6 months ago

Creating a SQLDatabase query engine

Creating a SQLDatabase query engine takes too long:

This single line
Plain Text
sql_database = SQLDatabase(engine)

Takes minutes to connect to the database and create the engine. Inspecting the python library I found that this function call
Plain Text
self._metadata.reflect(
            views=view_support,
            bind=self._engine,
            only=list(self._usable_tables),
            schema=self._schema,
        )

Is the thing that takes so much time, and erasing it does in fact reduce time to less than 5 seconds.

What does this do??? Is it neccesary???

Also i wanted to know if there is an async way of creating this engine, i did'nt find anything in docs
L
1 comment
I actually have no idea what this does, but pretty sure its needed. Its some slqalchemy operation
Add a reply
Sign up and join the conversation on Discord