ai:python-nl2sql
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ai:python-nl2sql [2024/05/01 11:01] – Wulf Rajek | ai:python-nl2sql [2024/05/02 13:25] (current) – Wulf Rajek | ||
---|---|---|---|
Line 15: | Line 15: | ||
<code python nl2sql.py> | <code python nl2sql.py> | ||
import openai | import openai | ||
- | from sqlalchemy import (create_engine, MetaData) | + | from sqlalchemy import (create_engine) |
from llama_index.core import SQLDatabase | from llama_index.core import SQLDatabase | ||
from llama_index.llms.openai import OpenAI | from llama_index.llms.openai import OpenAI | ||
Line 31: | Line 31: | ||
engine = create_engine(f" | engine = create_engine(f" | ||
- | |||
- | # load all table definitions | ||
- | metadata_obj = MetaData() | ||
- | metadata_obj.reflect(engine) | ||
sql_database = SQLDatabase(engine) | sql_database = SQLDatabase(engine) |
ai/python-nl2sql.1714557672.txt.gz · Last modified: by Wulf Rajek