GeminiPostSQL 1.1.0

dotnet add package GeminiPostSQL --version 1.1.0
                    
NuGet\Install-Package GeminiPostSQL -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GeminiPostSQL" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GeminiPostSQL" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="GeminiPostSQL" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GeminiPostSQL --version 1.1.0
                    
#r "nuget: GeminiPostSQL, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=GeminiPostSQL&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=GeminiPostSQL&version=1.1.0
                    
Install as a Cake Tool

See in spanish/Ver en español

GeminiPostSQL NuGet | AI-Assisted NuGet Package for PostgreSQL

image image image image image image NuGet

This is the NuGet Package version meant for developer use. There is a WinForms meant for client use, a REST API version meant for servers with Swagger and a ChatBot in Blazor for web clients.

This NuGet package uses Google's AI 'Gemini 2.0 Flash' to make queries to PostgreSQL databases.
The AI interprets natural language into SQL queries using one method, with its pros and cons.

📋 Prerequisites

To make this program work, you'll need a PostgreSQL Server and a Gemini API Key.

I will be using pgAdmin to build the PostgreSQL Server.

🛠️ Setup

If you don't have it, download pgAdmin 4 from the official website.
Now, create the PostgreSQL Server and set up a database with a few tables and insert values.

Next, obtain your Gemini API Key by visiting Google AI Studio. Ensure you are logged into your Google account, then press the blue button that says 'Create API key' and follow the steps to set up your Google Cloud Project and retrieve your API key. Make sure to save it in a safe place.
Google allows free use of this API without adding billing information, but there are some limitations.

In Google AI Studio, you can monitor the AI's usage by clicking 'View usage data' in the 'Plan' column where your projects are displayed. I recommend monitoring the 'Quota and system limits' tab and sorting by 'actual usage percentage,' as it provides further more detailed information.

You now have everything needed to make the program work.
Simply put that data you just got into the Client object.

📖 About the NuGet package

To use it, you must initialize the Client which has three methods:

GenerateSQL(string input): Translates natural language to SQL queries. In case the Client's parameter 'mapOnGenerateSQL' is activated, if 'jsonMap' is empty, it will automatically map the database into JSON. Returns the generated SQL in case of success, else will return an error message (they all start with '[ERROR]'). In case the Client's parameter 'runOnGenerateSQL' is activated, if succeeds, the method will return the a serialized JSON of the result table.

MapDatabase(): Maps the database into a serialized JSON. Returns a boolean value, depending if the mapping process were successful or not, if it is, the JSON is saved in the Client's parameter 'jsonMap'.

RunQuery(string generatedSql): Runs the generated query (or any) in the database server. Return the result table for the generated SQL sentence. If it fails, it will return a table with only one column named 'Error' with the description of the error.

You can test it's functionalities with the Test Demo

🚀 Releases

The version will be released using these versioning policies:
New major features and critical bug fixes will cause the immediate release of a new version, while other minor changes or fixes will wait one week since the time the change is introduced in the repository before being included in the new version, so that other potential changes can be added.

These potencial new changes will not increase the wait time for the new version beyond one week.

The version number will follow this format:
[Major Feature].[Minor Feature].[Bug Fixes]

💻 Technologies Used

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 98 6/20/2025
1.0.2 233 6/13/2025
1.0.1 276 6/12/2025

1.0.0 - Initial Release (had critical bugs making it unusable)
1.0.1 - Critical Bug Fix
1.0.2 - Bug Fix: runOnGenerateSQL didn't properly work
1.1.0 - Enhance: the returned errors will start with "[ERROR]" to identify errors easier