User Tools

Site Tools


ai:python-nl2sql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ai:python-nl2sql [2024/05/01 11:01] Wulf Rajekai: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"mysql+mysqlconnector://{username}:{password}@{host}:{port}/{mydatabase}") engine = create_engine(f"mysql+mysqlconnector://{username}:{password}@{host}:{port}/{mydatabase}")
- 
-# 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