Configuring Data Sources in GoLand IDE

Kacper Bąk
4 min readDec 24, 2022
Photo by Scott Graham on Unsplash

There is no single data source that can provide advanced code assistance for running an SQL query. Depending on the language and platform used to run the query, there are a variety of data sources that can be used. For example, if the SQL query is being run with MySQL, an IDE such as MySQL Workbench can be used to provide code assistance. If the query is being run with Microsoft SQL Server, tools such as Microsoft SQL Server Management Studio can be used to provide code assistance. Additionally, there are a variety of third-party tools available that can provide code assistance for running SQL queries.

The example IDE and source for the data will be MySQL for this article.

Okay, so I open my favorite editor, in which I program professionally on a daily basis. I create a SQL file, and to my eyes appears just such a thing. Everything lights up yellow, red, orange for me, in which case I need to configure the data source so that the editor can validate that the passed variables are valid and actually exist.

Damn… Everything is highlited.

To continue and do something with this data, we will need to know the database name, host, port, username and password.

To do this, we will also first need to create some database that we can connect to in order to proceed further.

Once we have created a database, we then need to connect to it using a database management system such as MySQL, PostgreSQL, SQLite, or MongoDB.

Once we have connected to the database, we can then use the database management system to create a table for the data we have collected. We can then use SQL commands to insert the data into the database table and store it. After the data is stored, we can then use SQL commands to query the data and retrieve the results.

Finally, we can use a programming language such as Python or JavaScript to manipulate the data and create visualizations, reports, and other useful data applications.

Cool, so let’s start by creating a MySQL database. Finally, we need to have something on which to test if the connection is established.

First, we will create a MySQL database. Open up the MySQL command line and type “CREATE DATABASE <database_name>” to create the database. Replace <database_name> with the name of the database you want to create.

Once the database is created, we need to create a table in the database. To do so, type “CREATE TABLE <table_name>(<column_name> <data_type>,…)” to create a table in the database. Replace <table_name> with the name of the table you want to create and <column_name> and <data_type> with the name of the column and its respective data type respectively.

Finally, we need to test if the connection is established. To do so, open up the MySQL command line and type “SELECT * FROM <table_name>;”. If the connection is established, this query should return the data from the table.

Create a new user by typing the following command:

CREATE USER ‘username’@’hostname’ IDENTIFIED BY ‘password’;

mysql> CREATE USER 'kacper'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0,02 sec)

Grant the new user permissions to the database by typing the following command:

GRANT ALL ON databasename.* TO ‘username’@’hostname’;

mysql> GRANT ALL ON mediumExample.* TO 'kacper'@'localhost';
Query OK, 0 rows affected (0,02 sec)

Flush privileges by typing the following command:

FLUSH PRIVILEGES;

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0,01 sec)

Exit the MySQL command line.

mysql> exit
Bye
Configured data source and drivers in GoLand IDE

Now you need to complete the drivers and data source by clicking on the appropriate link that popped up if you created the first SQL file.

Click ‘Test Connection’ to ensure the connection is successful.

Once the connection is successful, click ‘Save’. The SQL file is now complete and you can start running queries in the database.

A screenshot of the MySQL database that was created in the article.

It’s worth using this built-in database preview tool in the GoLand IDE, because it’s much easier to navigate and better visualizes what the database looks like, and the connections within it. It also simplifies the process of writing queries, as it allows you to quickly view the structure of the database and the data it contains. This makes it easier to debug queries and helps prevent errors. Additionally, it provides an easier way to explore and analyze the data in the database.

--

--