Find answers from the community

Updated 3 months ago

Multiple tables

I'm interested in SQL with multiple tables. I did the tutorial at https://gpt-index.readthedocs.io/en/latest/examples/query_engine/SQLAutoVectorQueryEngine.html but that is only a single table, is there an example with multiple tables?
L
J
3 comments
It handles multiple tables by default actually!

When you create the SQLDatabase object, you can specify which tables to include if you don't want to include them all

SQLDatabase(engine, include_tables=["table1", ...])

The table_name argument you see when constructing the SQL index is only used when you are ingesting new data
It will automatically handle joins and whatnot between tables

You can also include extra text descriptions (in addition to the automatic schema description) to help improve the text2sql bit (which usually helps quite a bit actually)
Add a reply
Sign up and join the conversation on Discord