Hello and welcome to the golden programming language course.
In the previous session, we could install gore and my school driver into project, so continue to create
a modern first go to Package Explorer and in Project Folder, create a folder named Model New Folder
and set a name like Modern.
In model folder, it create a file like named the student or go inside it because we are going to create
a structure equivalent to a student table in the MySchool database.
New find students that go so go to student file and create is not named a student with fields such as
fields east or inside the MySchool database.
First, that package model and create a strike named Student Time two that instruct.
Set to comment for this as an exporter, student, as student and defiant variables, I.D. and attack
for a field allows you to attach media information to the film, which can be secured using reflection.
Usually, it is used to provide transformation on highest ranked film is encoded to or decoded from
another format, but you can use it to restore whatever metal info you want to, either intended for
another package or for your own use.
So in this case, we use from all our intact for these films, for the example for Aida.
We write, set, go on and take back to each
go our own
column, double quotation mark and set primary.
Underscore key, so said primary key attribute for IED I.D.
and name five is estranged and said contact back Dick Gore and Colin.
Double quotation, Mark Android N. Vaca,
50 semicolon not.
So said Eastern character numbers and not not a status for name and go to the next line and age type,
is it and set another and take.
Google are
calling double quotation mark and said, not not.
So it not not a status or AIDS field.
OK, reformat the code and save the project.
Now go to Project Folder and create another folder named like configuration, which is supposed to include
the settings for the connection of the Go program with the MySchool database.
New father can be Grecian.
We want to create a database connection settings as adjacent, so inside the configuration folder,
we create the file called config with the JSON extension, new Fong config, the JS.
The program requires Maine sitting to connect to the database that is data source name, data source
name is a combination of username, password and database name that we want to connect it.
So be right adjacent five four sittings off database
data.
Source named as key calling and set value, my database username is Ruth.
Colin and my database passport is or I can.
And that's why this slash and database name is person.
And set any configuration, so put a question mark end of database nine and right other settings, for
example, Chad set equals UTF eight.
Pass time.
Equals.
True and large
equals look.
Reformat the code and save the project.
Now he could create adjacent file for connection to my school database.
It's time to go to Project Folder and create another package like DB tools for connection to the database.
You Father DB tools and create the fine inside it, like deep connection that gold that contains metals
to interact with the data base.
New five DB connection that go before do anything first import guar and miniscule driver type of database
tools package.
So we write these two lines first package these tools
import.
Go on and I'll ask that score.
And in the next line, Quantum Dot, I'll ask the writer and slash why is it
OK for using datasource name?
First, define the global variable named datasource name as a string type that.
Data source name as a street type
now create an initialized function to be able to initialize this variable from other packages.
This method receives one value named data source name as input parameter and uses it to initialize the
global variable of package.
Until that, other functions can access their values.
So override function
DB initialize or set a variable like this, and by the time it is string and initialize the data source
named global variable data source name equals D is.
And
now we want to design the method who is task is to connect the program to the MySQL database and return
it to the object from our end package.
For example, we create the function named Connie that is stored by the lowercase character because
we want to use this function just to this package, and we don't use it to either package it.
So we right fine connect.
And return type is the object by the time of Mr. Gore and Dot DB, DB Asterisk, Gore and Dot the B.
OK.
They required Metro to connect to the database is the open function of the gore and package.
So we should import car and package open function opens, initialize the decision by its dialectal and
gore config option, and it returns a DB object of gore and error, as Stuart is the programming language
used to talk to those databases, and each database product has its own variant of school.
So we call this variance in school.
Dialects first defined two variables like Debian Roller Derby, Croma, error calling equals and calling
open function from gore and package gore and dot open function.
And said, dialectal an option as input parameter for dialect parameter, we can't open function from
miniscule package and sit data source name as input parameter for it.
So we write minuscule thought open and set data, source name, data, source name, comma and forgotten
config option.
We write ampersand and select configure straight from gore and package.
Anderson Cooper and Dot can speak.
Now, check our status if error like that fatal error to enroll and return created TBE object as return
type returned DB reformat the call and say the project so we could define the database dialect for connecting
to a database.
In order not to prolong the time of decision, we will finish you, then we will continue the content
in the next session.
Goodbye.