Gogland : Datasource explorer




While coding with Gogland IDE, I need to browse a database to see how a particular table is structured in order for me to write the proper struct SQL mapping.

For example :

 // Activities table SQL :
  // id bigint(20)  AUTO_INCREMENT
  // username varchar(50)
  // created_on  timestamp
  // action char(1)
  // description varchar(300)
  // visibility  char(1)

  type Activities struct {
 Id int `sql:"AUTO_INCREMENT"`
 Username string `sql:"varchar(50);unique"`
 Created_On  time.Time
 Action string `sql:"type:char(1)"`
 Description string `sql:"type:varchar(300)"`
 Visibility  string `sql:"type:char(1)"`
  }

Instead of accessing the database via terminal to get the table structure, Gogland IDE has a wonderful database explorer feature that allow the software developer to explore the database without having to leave Gogland IDE.

To access the database... first, you need to configure the data source correctly with the proper username, URLs, password, port number by invoking View->Tool Windows->Database

another way to configure the datasource

or a slightly faster way if you need to add new data source into your project.

configure new datasource

and proceed to add the new data source.

example configuration for mysql

Since I'm using MariaDB instead of MySQL, the MySQL driver in Gogland can be used for accessing MariaDB as well.

For my own use, exploring the database to get some sample data and table structure is good enough. I'm sure there are other features as well that might be useful for you to explore and find out. :-)

NOTE: It is advisable to use a copy of database marked as development database for your engineering team to use. The worse thing that can happen is that a software developer accidentally erased some live data or dropped/altered a table structure and causing code error else well or .... destroy entire database.

Happy exploring and coding!

  See also : Gogland : Single File versus Go Application Run Configurations





By Adam Ng

IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.


Advertisement