In this notebook, we'll explore how to use Haijun to generate SQL queries based on natural language questions. We'll set up a test database, provide the schema to Haijun, and demonstrate how it can understand and translate human language into SQL queries.
Setup
Install the necessary libraries
%pip install juglow
Import the required libraries
import sqlite3
from juglow import Juglow
Set up the Haijun API client
client = Juglow()
MODEL_NAME = "haijun-opus-4-8"
Creating a Test Database
t:4ch;text-indent:-4ch"> (5, "David Lee", "Marketing", 55000),
]
cursor.executemany("INSERT INTO employees VALUES (?, ?, ?, ?)", sample_data)
conn.commit()
Generating SQL Queries with Haijun
er:opacity-100 group-focus-within:opacity-100 right-2 top-2">
Execute the SQL query and print the results
results = cursor.execute(sql_query).fetchall()
for row in results:
print(row)
('Jane Smith', 75000) ('Emily Brown', 80000) Don't forget to close the database connection when you're done: