Skip to content

Latest commit

 

History

History
82 lines (65 loc) · 4.11 KB

File metadata and controls

82 lines (65 loc) · 4.11 KB

Database Setup Instructions

Issue: Database Permissions

Your chatbot is currently showing empty results because:

  1. Wrong table names: The code was using incorrect table names like finances_fund_plan instead of finances_fund (as per PRD)
  2. No sample data: The finances_fund table exists but has no data
  3. Limited permissions: Your current database user doesn't have INSERT permissions

✅ Solutions (Fixed)

1. Code Updates ✅

I've already updated all backend tools to use the correct table name finances_fund:

  • search_funds.py
  • analyze_performance.py
  • sector_analysis.py
  • risk_return_scatter.py
  • correlate_performance.py
  • nav_trend_analysis.py

2. Database Setup (You need to do this)

Option A: Create table + Add data (if you have admin access)

# If you have database admin access, run:
psql -U your_admin_user -d mutual_funds -f create_table.sql
python seed_data.py

Option B: Manual SQL (if table already exists)

-- Connect to your database and run this manually:
INSERT INTO finances_fund (
    fund_id, name, full_name, amc_name, amc_short_name, 
    asset_class, sub_asset_class, sebi_category_name,
    nav, nav_date, aum, return_1year, return_3year, return_5year,
    return_since_launch, fund_expense_ratio, risk_level,
    fund_recommendation_rating, min_initial_investment,
    is_sip_allowed, is_active_status, is_direct
) VALUES 
(gen_random_uuid(), 'ICICI Prudential Bluechip Fund', 'ICICI Prudential Bluechip Fund - Direct Plan - Growth', 'ICICI Prudential Mutual Fund', 'ICICI Prudential', 'Equity', 'Large Cap', 'Large Cap Fund', 89.45, '2024-01-10', 45000000000, 0.18, 0.15, 0.12, 0.14, 0.52, 'High', 4, 5000, true, true, true),
(gen_random_uuid(), 'SBI Small Cap Fund', 'SBI Small Cap Fund - Direct Plan - Growth', 'SBI Mutual Fund', 'SBI', 'Equity', 'Small Cap', 'Small Cap Fund', 145.67, '2024-01-10', 12000000000, 0.28, 0.22, 0.19, 0.21, 0.65, 'Very High', 5, 5000, true, true, true),
(gen_random_uuid(), 'HDFC Corporate Bond Fund', 'HDFC Corporate Bond Fund - Direct Plan - Growth', 'HDFC Mutual Fund', 'HDFC', 'Debt', 'Corporate Bond', 'Corporate Bond Fund', 22.89, '2024-01-10', 8500000000, 0.06, 0.065, 0.07, 0.068, 0.35, 'Low', 3, 5000, true, true, true),
(gen_random_uuid(), 'Axis Midcap Fund', 'Axis Midcap Fund - Direct Plan - Growth', 'Axis Mutual Fund', 'Axis', 'Equity', 'Mid Cap', 'Mid Cap Fund', 67.23, '2024-01-10', 18000000000, 0.25, 0.18, 0.16, 0.17, 0.58, 'High', 5, 5000, true, true, true),
(gen_random_uuid(), 'Mirae Asset Large Cap Fund', 'Mirae Asset Large Cap Fund - Direct Plan - Growth', 'Mirae Asset Mutual Fund', 'Mirae Asset', 'Equity', 'Large Cap', 'Large Cap Fund', 112.34, '2024-01-10', 25000000000, 0.16, 0.14, 0.13, 0.135, 0.45, 'High', 4, 1000, true, true, true);

Option C: Grant permissions to your current user

-- Ask your DB admin to run:
GRANT INSERT, UPDATE, DELETE ON finances_fund TO your_current_user;
-- Then run: python seed_data.py

3. Test Your Chatbot

Once you add the sample data, restart your backend and test these prompts in the chatbot:

  • "hello" → Should get a friendly chat response
  • "show me the top 5 funds by return" → Should show fund performance data
  • "find large cap funds" → Should filter by asset class
  • "which funds have the highest AUM?" → Should show AUM-sorted results
  • "compare equity vs debt funds" → Should show sector analysis

4. What's Fixed

Frontend: Routes all prompts to /nl2sql for hybrid behavior
Backend: Robust fallback from data queries to general chat
Schema: All tools use correct finances_fund table name
Hybrid Chat: Handles both general questions and data queries

5. Current Status

  • Backend: Ready and properly configured
  • Frontend: Ready and properly configured
  • ⚠️ Database: Needs sample data (see options above)

Once you add the sample data, your chatbot will be a true hybrid assistant that can:

  • Answer general questions (weather, coding, etc.)
  • Provide mutual fund insights from your database
  • Gracefully fallback between the two modes