The Real NoSQL? Chatting with MySQL in Plain English (and French!)


You can now interact with a database in English—the real NoSQL 🙂

As someone who has done a lot of database administration and written a lot of SQL queries in the past, this is the stuff of dreams!

So this week when Google announced Gemini CLI extensions, I was particularly interested in the new database extensions which allow you to interact with MySQL and PostgreSQL using natural language. I also tried it in French, and it works, including giving the query feedback also in French.

Here’s a guide to get started if you want to try yourself:

Prerequisites

  • You need to have a MySQL server installed and running.
  • You will need the wget and unzip command-line utilities.

Step 1: Download the Sakila Sample Database

First, you need to download and unpack the sample database files from MySQL. These commands will download the zip archive and extract the SQL files into a new directory called sakila-db.

Bash

# Download the official Sakila database archive
wget https://downloads.mysql.com/docs/sakila-db.zip

# Unzip the archive
unzip sakila-db.zip

After running these commands, you should have the sakila-schema.sql and sakila-data.sql files inside the sakila-db directory.

Step 2: Install the Gemini CLI

Next, install the Gemini Command Line Interface (CLI). Open your terminal and run the following command. This will download and run the installation script.

Bash

/bin/bash -c "$(curl -fsSL https://storage.googleapis.com/gemini-one-comp-a-us-central1-prod-new/installer.sh)"

Follow the on-screen instructions to complete the installation.

Step 3: Install the MySQL Extension

The Gemini CLI uses extensions to connect to different tools and services. To connect to your database, you’ll need to install the MySQL extension.

Bash

gemini extension install mysql

You can check the installed extensions and available command by running this command in gemini cli:

/mcp list 

Step 4: Set up the Sakila Sample Database

Now, we’ll load the Sakila database into your MySQL server. This database, which models a DVD rental store, will provide a good dataset for testing queries.

  1. Create the database:Bashmysql -u YOUR_USERNAME -p -e "CREATE DATABASE sakila;" (Replace YOUR_USERNAME with your MySQL username. You will be prompted for your password.)
  2. Import the schema (the table structures):Bashmysql -u YOUR_USERNAME -p sakila < sakila-db/sakila-schema.sql
  3. Import the data:Bashmysql -u YOUR_USERNAME -p sakila < sakila-db/sakila-data.sql

Step 5: Configure the Database Connection

The Gemini CLI needs to know how to connect to your database. It uses environment variables for this. You’ll need to set these in your terminal.

Important: For the extension to work, you must set these variables before you start the Gemini CLI.

Bash

export MYSQL_HOST="localhost"
export MYSQL_PORT="3306"
export MYSQL_DATABASE="sakila"
export MYSQL_USER="YOUR_USERNAME"
export MYSQL_PASSWORD="YOUR_PASSWORD"

(Replace YOUR_USERNAME and YOUR_PASSWORD with your MySQL credentials).

Step 6: Start Gemini CLI and Query in English

Now you’re ready. Start the Gemini CLI:

Bash

gemini

Once it’s running, you can start asking it questions about the database in plain English. The MySQL extension will translate your questions into SQL queries and show you the results.

Example Prompts:

Try asking some of these questions. You don’t need to know any SQL!

  • list all tables in the database
  • show me the top 10 most rented films
  • who are the top 5 customers by total payment amount?
  • find all films in the 'Action' category starring 'NICK WAHLBERG'
  • what is the average rental duration for films rated 'PG-13'?

You can now explore the database just by having a conversation.

Even in French!