Skip to main content

ChatGPT as a MariaDB database

·230 words·2 mins
Alejandro Duarte
Author
Alejandro Duarte
Alejandro Duarte is a Software Engineer, published author, and Developer Relations Engineer at MariaDB. He has been programming computers since the mid-90s. Starting with BASIC, Alejandro transitioned to C, C++, and Java during his academic years at the National University of Colombia. He relocated first to the UK and then to Finland to foster his involvement in the open-source industry. Alejandro is a recognized figure in Java and MariaDB circles.

ChatGPT is truly impressive. You can instruct it to do all sorts of things when they can be communicated in plain text. Software developers are already using it to write code or improve SQL queries, among many other things. But ChatGPT can also act as software. For example, if you tell it the following:

Act as the mariadb command line tool.
Only reply to commands with output in one single code block.
Do not write any explanations.
Expect English messages in {curly brackets}.
My first command is SELECT VERSION();

Then you’ll get this answer:

Isn’t that impressive? There. Now you have a new way to get started with MariaDB without installing anything. I mean, that was even faster than using Docker on your browser!

Let’s show the available databases (or schemas):

SHOW DATABASES;

Can we create a new database?

CREATE DATABASE test;

Yes, we can! How about creating a new table and inserting data?

CREATE TABLE test.messages(content TEXT);
INSERT INTO test.messages VALUES("Hi MariaDB đź‘‹");

Query OK, 1 row affected. It seems to be working! Let’s double-check that the data is stored:

SELECT * FROM test.messages;

Hi MariaDB đź‘‹! This is so cool! Open a new tab in your browser and try it out to see it in action.

When you want to stop ChatGPT from acting like a MariaDB database, just tell it to do so:

{stop acting like mariadb}
Enjoyed this post? I can help your team implement similar solutions—contact me to learn more.