1 00:00:11,720 --> 00:00:14,990 Hello and welcome to the Golang programming language course. 2 00:00:15,470 --> 00:00:21,320 In the previous session, we could define the function name, select all a student that fits all students 3 00:00:21,320 --> 00:00:22,370 from the database. 4 00:00:23,000 --> 00:00:26,780 And in this time, we want to create a main function. 5 00:00:27,980 --> 00:00:34,610 So we create a new package named Main and create a finding inside name main that goal. 6 00:00:35,450 --> 00:00:39,920 And in this fine first, we create the main function to execute queries. 7 00:00:40,190 --> 00:00:54,800 So go to Project Explorer and create a new package, for example, named Main and create a new file 8 00:00:54,800 --> 00:00:57,560 inside it like name. 9 00:00:58,130 --> 00:01:06,500 The article said the package main and create the main function for me. 10 00:01:10,400 --> 00:01:16,370 Before we can access data in the MySQL database, we need to create a connection to the database. 11 00:01:16,970 --> 00:01:23,660 Previously, we designed the method called König in the DB Tools package, which contains a method called 12 00:01:23,660 --> 00:01:25,490 open from this school package. 13 00:01:25,730 --> 00:01:32,330 This by taking two values of driver name and data source name creates a connection to the MySchool database. 14 00:01:32,960 --> 00:01:40,550 We also previously saved driver name and data source name information inside the JSON file in the configuration 15 00:01:40,550 --> 00:01:41,060 package. 16 00:01:41,510 --> 00:01:50,060 Now it's time to use the information our JASON file to connect to the database for using the JSON file 17 00:01:50,060 --> 00:01:55,820 weakening open function from Always Package that opens the named file from Reading. 18 00:01:56,390 --> 00:02:04,460 If successful methods on the return file can be used for reading this function except fine pass as input 19 00:02:04,460 --> 00:02:07,010 parameter and returns tool value. 20 00:02:07,220 --> 00:02:11,230 First, not from file and the other an object from, you know. 21 00:02:11,450 --> 00:02:21,020 So first, define two variables named file and or find and ETL columns equals calling. 22 00:02:21,020 --> 00:02:29,570 Open function from Westpac is open function and Sanjay some file pass as input parameters as the string 23 00:02:29,570 --> 00:02:42,800 type can be Grecian slash config that JS check error status. 24 00:02:49,110 --> 00:03:03,510 Like the fat on air or God, views differ for closing the created final object, the author fired close. 25 00:03:05,210 --> 00:03:12,350 Now, create this right on top of the main method that contains variables equivalent to the keys in 26 00:03:12,350 --> 00:03:17,230 the JSON file that are used to map those keys to their data types in column. 27 00:03:17,690 --> 00:03:20,750 So define airstrike like name, configuration, 28 00:03:25,550 --> 00:03:26,210 type, 29 00:03:28,880 --> 00:03:30,500 configuration 30 00:03:32,420 --> 00:03:32,960 structure 31 00:03:35,810 --> 00:03:36,960 and define value. 32 00:03:36,980 --> 00:03:40,850 The driver name 33 00:03:43,700 --> 00:03:47,690 type is string and using Jason. 34 00:03:47,870 --> 00:03:56,630 Thank you, Jason, Colin and Seth. 35 00:03:56,630 --> 00:04:01,910 Write your name to write a name. 36 00:04:03,450 --> 00:04:15,420 Go to the next line and find another valuable four data source name data, source name five is a swing 37 00:04:17,010 --> 00:04:19,240 and set Jason Tech. 38 00:04:21,600 --> 00:04:24,240 Jason Collins. 39 00:04:28,360 --> 00:04:32,830 Data source me. 40 00:04:35,200 --> 00:04:41,520 OK, now go to the main function and create an object from this configuration estrogen. 41 00:04:42,770 --> 00:04:49,280 So define a variable like con call and he calls new configuration. 42 00:04:55,850 --> 00:05:03,020 Now, using the new decoder function of the Jason package, we sent the Jason fine to eat as a parameter 43 00:05:03,020 --> 00:05:10,100 after opening it and through the decode method and read the next Jason encoded value from its input 44 00:05:10,400 --> 00:05:15,020 and installs it in the values pointed to Archer created from the configuration. 45 00:05:15,950 --> 00:05:26,420 So be right, Jason Dot, new decoder, said fine as argument. 46 00:05:28,670 --> 00:05:36,620 And Colleen Deckard function and sit calm first and put perimeter. 47 00:05:37,760 --> 00:05:38,200 OK. 48 00:05:38,690 --> 00:05:45,110 This allowed us to sort of values inside the JSON, find in the variables in the configuration is not 49 00:05:45,140 --> 00:05:45,710 object. 50 00:05:46,280 --> 00:05:52,580 Now it's time to call the DB initialize method from the DB tools package to connect to the database 51 00:05:52,970 --> 00:06:00,320 so the right DB tools dot db initialize. 52 00:06:03,960 --> 00:06:06,220 Said Driver made from Kong object. 53 00:06:06,240 --> 00:06:06,870 Com. 54 00:06:07,080 --> 00:06:13,060 Dutch driver name and set data source name from conf object. 55 00:06:13,080 --> 00:06:17,070 Com The data source name. 56 00:06:20,640 --> 00:06:21,000 OK. 57 00:06:22,200 --> 00:06:27,960 Each of the current methods uses a method called conic to communicate with the database, which requires 58 00:06:27,960 --> 00:06:33,210 these two parameters that we were able to inject into the attitudes package. 59 00:06:33,660 --> 00:06:38,640 Necessary conditions for communication with the MySchool database are provided. 60 00:06:39,030 --> 00:06:44,520 Now it's time to call on the available methods to perform crowd Operation DB Tools package. 61 00:06:45,000 --> 00:06:51,480 In this case, we want to select all the students in the person database, so we should use from select 62 00:06:51,480 --> 00:06:54,000 all the students function from DB tools. 63 00:06:54,300 --> 00:06:59,370 First, define a variable like a student, for instance, the needs of all students. 64 00:06:59,610 --> 00:07:11,730 So we write a student's column he calls DB Tools Package Dart, calling Sediq all his students function 65 00:07:13,350 --> 00:07:15,600 to iterate the values inside this student. 66 00:07:15,630 --> 00:07:24,780 We use a range loop so that we can display the values inside each record separately for under a school 67 00:07:25,200 --> 00:07:26,940 comma set the variable. 68 00:07:26,940 --> 00:07:33,150 For example, a student column equals range in a student's. 69 00:07:37,100 --> 00:07:52,200 And he printed information to display each record that fee I.D., Caller ID, student I.D.. 70 00:07:58,390 --> 00:08:11,500 Comma and set back list for create a ton of space that has less teeth and name calling the student name 71 00:08:15,670 --> 00:08:17,540 and said another bike as close to. 72 00:08:19,680 --> 00:08:33,840 Age, Colin and Student Start page reformat the cold and save the project, now execute the program, 73 00:08:36,210 --> 00:08:38,310 go from Dot. 74 00:08:38,610 --> 00:08:38,970 Thank you. 75 00:08:38,990 --> 00:08:42,150 Slash main Maine Dot Go. 76 00:08:45,120 --> 00:08:46,660 We can see the output. 77 00:08:47,160 --> 00:08:54,660 Now we could select all a students from person database and display each record separately in order 78 00:08:54,660 --> 00:08:56,490 not to prolong the time of decision. 79 00:08:56,670 --> 00:09:00,450 We will finish it and we will continue the content in the next session. 80 00:09:00,600 --> 00:09:01,110 Goodbye.