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 award winner. He currently works for MariaDB plc as a Developer Relations Engineer. Starting his coding journey at 13 with BASIC on a rudimentary black screen, Alejandro quickly transitioned to C, C++, and Java during his academic years at the National University of Colombia. Relocating first to the UK and then to Finland, Alejandro deepened his involvement in the open-source community. He’s a recognized figure in Java circles, credited with articles and videos amassing millions of views, and presentations at international events.

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.