Member-only story
Interacting with a RDBMS using Ballerina

Ballerina is an open-source programming language. It’s a language that was designed with cloud in mind and has superior support for network interactions that’s essential for modern application design. It also got an extensive standard library for common operations that’s needed for application programming. In this short post I’ll walk you through how ballerina enables a developer to interact with a RDBMS.
Let’s first begin by installing the ballerina.
Installing Ballerina
As the first step, you need to get ballerina installed. The latest version of ballerina can be downloaded from here for your OS. In Windows and MAC OS you can double click on the downloaded executable and follow the onscreen instructions. In Linux execute the relevant commands to install .deb or .rpm files.
Once successfully installed and binaries are in the system executable path, you should have no trouble with below commands.
balbal version
It’s also recommended to install ballerina VSCode extension for development. It provides syntax coloring, intellisense and more for developers to easily get into ballerina programming.
Creating the database
For demonstration purpose I’m going to use a database to store simple product information. For the purpose of this post I’m going to use MySQL. Hope you have MySQL setup in your OS. If not get it installed for your system.
Ballerina doesn’t support ORM yet. But this is in the roadmap. We’ll have to wait and see what functionality it might bring in. Typically it should bring in capability to define the underlying model in the language it self and make DDL executed automatically to create the schema.
In the meantime, we’ll have to setup the tables and execute SQL to interact with the database from the language which we’ll see later.
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.25 HomebrewCopyright (c) 2000, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle…