DEV Community

Cover image for Check Out GomorraSQL — A Library To Write Queries in Neapolitan
Antonello Zanini for Writech

Posted on • Originally published at writech.run

Check Out GomorraSQL — A Library To Write Queries in Neapolitan

Over the past few days, GomorraSQL's been making waves and trending in the Italian IT community. I've read thousands of posts on Twitter and LinkedIn mentioning this project, so I couldn't resist looking into it. Created by Donato Rimenti, GomorraSQL is inspired by the Italian television series Gomorrah and allows you to query a database in Neapolitan.

Although these kinds of projects shouldn't be taken too seriously, they do play a crucial role in the IT community. Let's find out why.

What Is GomorraSQL?

GomorraSQL's logo

First of all, let's try to understand what GomorraSQL is:

"GomorraSQL is an easy and straightforward interpreted SQL dialect that allows you to write simpler and more understandable queries in Neapolitan language." — GomorraSQL's GitHub page

As stated in the official documentation, GomorraSQL can be used both as a Java library and as a standalone SQL database client. At the time of writing, the project officially supports only MySQL and H2, but other RDBMS technologies may be added to the list in the future.

How To Use GomorraSQL

As mentioned earlier, GomorraSQL can be used in two ways. Let's see them both.

1. Java Library

First, download the latest GomorraSQL.jar from GitHub. Then, import it into your project. You will also need a database driver. Now, you can start using GomorraSQL employing the methods exposed by the GomorraSqlInterpreter class, which requires a valid Connection object to be instantiated.

GomorraSqlInterpreter allows you to either execute a GomorraSQL query against your database or translate queries written in Neapolitan into plain SQL. Please note that whenever an error occurs, a CaggiaFaException (literally WhatShouldIDoException) providing useful debugging information will be thrown.

2. Database Client

First, download the latest GomorraSQL.jar from GitHub. Then launch it with the following command:

java -cp gomorra-sql-1.0.0.jar;<path_to_your_db_driver> co.aurasphere.gomorrasql.GomorraSqlShell
Enter fullscreen mode Exit fullscreen mode

The client will ask for a JDBC string representing the database to connect to (including credentials). As soon as the connection is established, you can start executing GomorraSQL commands.

GomorraSQL in Action

Before seeing GomorraSQL in action, you should take a look at these rules:

  • Parentheses are not valid characters in GomorraSQL queries.

  • GomorraSQL doesn't allow multi-line queries.

  • Spacing is required when using operators (e.g. a query including a = 5 will work, but the same query with a= 5 or a =5 or a=5 will not).

Although I am not a Neapolitan myself, I find writing queries in GomorraSQL to be a fun and wholesome experience.

Now, it's time to see some GomorraSQL queries compared to their SQL counterparts:

GomorraSQL

1) retrieving all users' data
ripigliammo tutto chillo ch'era 'o nuostro mmiez 'a users
2) retrieving all the emails of the users with id 6 or null name
ripigliammo email mmiez 'a users arò id = 6 o name è nisciun
3) deleting all users' data 
facimm na' strage mmiez 'a users
4) setting the name "Ciro" for all the users
rifacimm users accunza name accussì "Ciro"
5) inserting a new user by setting only their name
nzipp 'ngoppa users name chist "Ciro"
Enter fullscreen mode Exit fullscreen mode

SQL

1) retrieving all users' data
SELECT * FROM users
2) retrieving all the emails of the users with id 6 or null name
SELECT * FROM users WHERE id = 6 OR name IS NULL
3) deleting all users' data 
DELETE FROM users
4) setting the name "Ciro" for all the users
UPDATE users SET name = "Ciro"
5) inserting a new user by setting only their name
INSERT INTO users(name) VALUES ("Ciro")
Enter fullscreen mode Exit fullscreen mode

Et voilà! You are now ready to start querying your database like a character on Gomorrah would!

Why Such Projects Are Important

Although you should not expect to use such a library in real-world applications, these projects are more important than they may seem. First, they are apt to go viral. In fact, anyone is willing to reshare them — not only developers. Consequently, they can reach many more people than any other IT project. Second, they are created and maintained for fun, proving the entertaining side of coding.

Both of these points suggest how such fun-based projects can help curious people gain interest in the IT community and engage with it. They may not revolutionize the world or be incredibly forward-looking technologies, but they do play a role in introducing new people to the world of development.

That's why supporting them may be more meaningful than expected.

Conclusion

In this article, we looked at GomorraSQL, an interpreted SQL dialect allowing you to write queries in Neapolitan. While this cannot be taken too seriously, similar projects play a major role in helping curious people approach and enter the world of coding. This makes these projects more relevant than they may seem — especially considering their ultimate usefulness.

Thanks for reading! I hope that you found this article helpful.


The post "Check Out GomorraSQL — A Library To Write Queries in Neapolitan" appeared first on Writech.

Top comments (0)