Hello and welcome to the Golang programming language course in the previous session, we could define
to create the save method and insert some records into the database and in decision, we want to create
the function to select the statement, to fetch all the student records from person database.
So go to DB connection that go, find and define the function name select find.
Select
this function.
Accept a slice of A-student as parameter and retrieve all students of a student table in person database.
So we write a student's object as parameter to students.
A slice of mother law student.
Now cutting connect function for initializing MySchool data source name, this function returns a DB
object from gore and package.
So first, define a variable like DB calling equals and calling connect function.
After creating a DBI object from GLAA and package the Invoke Find function, this function, except
it is life of a student instance, then running said Aquarium is student table and feel a student's
life by fishing his students from a database and return it.
So we ride DB dot culling, find function and select a students.
Enter students.
Now we use the range blue to display each member in the student list.
So we write for on the school set a variable like a student, Cullen equals range in the student's.
And now calling printer functions from 50 pages to display each record.
If Earth
now using Person B for a student I.D. and sit back A for creates space and person s for Essendon name
and a game that is thirsty and for a student age percent d and sit like this and to go to the new line
and set variables as student darts I.D., the student name and a student start page.
OK, reformat the coat and save the project.
Now we could create the function fonctionnent silhouette that fits all students.
It's time to go to the main function to use this query statement.
So go to the main file and go to the main function.
First, clear the last code.
In this case, we want to select honest students from person database, so first, create a slice of
student is less than the student's slice of model of the student now cutting select function from debate
rules, package and pass students slice as arguments to eat daily tools, dot, select and pass students.
Reformat the court, save the project and execute the program, go run dot backsplash, Maine and Maine
that go.
Now we can see the output, all the students are displayed.
We could create a select function that fits all members of student data in person database in order
not to prolong the time of decision.
We will finish it and we will continue the content in the next session until next session.
Goodbye.