Text2SQL.ai logo

AI Assistant

Published on

Text2SQL.ai's AI assistant helps you generate SQL queries, fix errors, and optimize your database interactions through natural language conversations.

Starting a New Conversation

There are two ways to start a new conversation with the assistant:

  1. Start New Chat

    • Click "New Chat" in the sidebar or navigate to the Home page
    • Enter your question or request in the input field
    • Recommended - Select a database connection for context
    • Press Enter or click the send button to start the conversation
  2. Using Templates

    • Choose from pre-built templates for common tasks:
      • Generate SQL from text descriptions
      • Fix SQL syntax errors
      • Optimize SQL queries
      • Generate regex patterns
      • Create spreadsheet formulas
    • Fill in the template details
    • The assistant will process your request using the template format

Ask Follow-ups

The assistant maintains context throughout your conversation, allowing you to:

  • Refine your queries
  • Ask for explanations
  • Request optimizations
  • Debug errors
  • Get clarification on previous responses

Best Practices

  1. Provide Context

    • Configure and link a database connection when possible. Make sure you have selected a type and entered a detailed schema. You can find more information here: Database Connections
  2. Clear Communication

    • Be specific in your requests
    • Break complex queries into smaller steps
    • Include example data or expected results when relevant

Example Interactions

  1. Generate a Query

    User: Show me all orders from the last 7 days
    Assistant: Based on your schema, here's a query to fetch recent orders:
    
    SELECT *
    FROM orders
    WHERE order_date >= CURRENT_DATE - INTERVAL '7 days'
    ORDER BY order_date DESC;
    
  2. Fix an Error

    User: This query isn't working: SELECT * FORM users;
    Assistant: I spotted the error. "FORM" should be "FROM". Here's the corrected query:
    
    SELECT * FROM users;
    
  3. Optimize a Query

    User: How can I make this query faster?
    SELECT * FROM orders WHERE EXTRACT(YEAR FROM order_date) = 2024;
    
    Assistant: Here's an optimized version using a more efficient date comparison:
    
    SELECT * FROM orders
    WHERE order_date >= '2024-01-01'
    AND order_date < '2025-01-01';
    

Access Past Conversations

  • View your chat history in the sidebar
  • Search through previous conversations
  • Reuse successful queries from past interactions
  • Continue previous conversations where you left off