User Tools

Site Tools


ai:python-nl2sql

Differences

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

Link to this comparison view

Next revision
Previous revision
ai:python-nl2sql [2024/04/30 02:26] – created Wulf Rajekai:python-nl2sql [2024/05/02 13:25] (current) Wulf Rajek
Line 14: Line 14:
  
 <code python nl2sql.py> <code python nl2sql.py>
-import os 
 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 32: 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.1714440419.txt.gz · Last modified: by Wulf Rajek