Step 1: Connect to Your Database
- Go to Lyzr Agent Studio → Database Connections.
- Choose your database type from the available options (e.g., PostgreSQL, MySQL, Snowflake, Databricks, etc.).
- Add your database credentials and connect.
Step 2: Create a Semantic Model
You typically don’t want your agent to access the entire database — that can overload its context and cause slow performance or hallucinations. Instead, pick only the relevant tables and columns your agent needs to analyze. For example, for car sales data, you only need the car_sales table.- Go to Knowledge Base → click Create New.
- Choose Semantic Model from the pop-up and click Create.
- Give it a name and description.
- Select Vector Store and Embedding Model (defaults are pre-filled if you’re unsure).
- Finally, select the database you just connected.
Step 3: Generate Schema Documentation
Before finalizing your semantic model, create a Schema Documentation Agent. This agent automatically reads tables and columns to generate helpful descriptions, so your data analyst agent can understand your schema better.- Go to Schema Documentation Agent → click Create New.
- Enter a name, choose your LLM provider and model, and click Submit.
Step 4: Configure Tables and Columns
After creating your semantic model, you’ll see a screen divided vertically:- Left Panel: Lists all tables in your connected database.
- Right Panel: Shows columns and their auto-generated descriptions when you click Configure on a table.
Auto-generated: “Listed selling price of the car in dollars.” Updated: “Listed selling price of the car in Indian Rupees..”After reviewing and updating descriptions, click Save and Add to Semantic Model. You can repeat this for additional tables, but it’s best to keep your model as lean as possible for efficiency.
Step 5: Build Your Data Analyst Agent
- Go to Agents → click Create New Agent.
- Give it a name, description, and select a suitable model.
- Define the following:
- Role: Expert Data Analyst
- Goal: Analyze Car Sales Data and Provide Insights
-
Instructions:
“You are an expert data analyst. Analyze the provided car sales data and answer user questions quantitatively. Use the connected semantic model to interpret data before responding.”
- You can give accurate role, goal & instructions as per your use case
- Enable Memory in Core Features to make the agent conversational.
- Enable Data Query, select the Semantic Model you created, and click Save.
Step 6: Test Your Agent
You can now ask your agent natural-language questions like:- “What is the average selling price of SUVs in 2024?”
- “Which city recorded the highest car sales last quarter?”
- “Show the total number of cars sold by brand.”
Behind the scenes, the agent automatically converts your question into SQL, runs it against your connected database, and provides an easy-to-understand answer.
You now have a fully functional Data Analyst Agent that connects securely to your database, understands schema context via semantic models, and provides data-driven insights — without writing a single line of SQL.