What is Best AI Model for SQL and MongoDB Query Generation

Harinath J 0 Reputation points
2025-02-19T13:37:08.48+00:00

Hi Azure Community,

I’m working on a project that requires generating SQL and MongoDB queries dynamically based on user inputs. I’m looking for the best AI model that can handle:

  • Complex SQL query generation (including joins, aggregations, and conditions)
  • MongoDB query generation with appropriate filters and aggregations
  • Seamless integration with Azure services like OpenAI, Cognitive Search, or other AI offerings

Would Azure OpenAI’s GPT models (like GPT-4-turbo) be suitable for this? Or are there other pre-trained models optimized for database query generation?

Looking forward to your insights!

Thanks in advance.

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,709 questions
{count} votes

1 answer

Sort by: Most helpful
  1. santoshkc 12,505 Reputation points Microsoft Vendor
    2025-02-19T16:28:18.14+00:00

    Hi @Harinath J,

    For your project requiring dynamic generation of complex SQL and MongoDB queries based on user inputs, Azure OpenAI's GPT-4 models is a highly suitable choice. GPT-4 models is a multimodal large language model capable of processing both text and image inputs to generate text outputs, making it adept at understanding and generating natural language and code. This capability enables it to handle intricate SQL queries involving joins, aggregations, and conditions, as well as MongoDB queries with appropriate filters and aggregations.

    Integrating GPT-4 models with Azure services can enhance your application's functionality. For instance, combining Azure OpenAI with Azure AI Search allows for retrieval-augmented generation (RAG), enabling the model to access and utilize your data effectively. This integration facilitates the generation of contextually relevant database queries based on user inputs.

    Additionally, Azure Cosmos DB for MongoDB vCore offers native support for integration with Azure OpenAI, streamlining the process of generating and executing MongoDB queries. This seamless integration ensures efficient handling of MongoDB operations within your application.

    While Azure OpenAI's GPT-4 models is a robust solution, there are other AI-powered tools specifically designed for query generation.

    For more info, please refer to:

    I hope this information helps! Thank you.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.