1
00:00:01,100 --> 00:00:01,790
Welcome back.

2
00:00:02,270 --> 00:00:12,320
Now we need to do is that we need to connect to the database and get get your get all movies from a

3
00:00:12,320 --> 00:00:14,630
database because this is the first.

4
00:00:15,410 --> 00:00:19,550
This one is the first route that we have, which is to get movies, get on.

5
00:00:20,420 --> 00:00:27,860
So in order to get movies, the first step is that we need to use what's called a cursor because the

6
00:00:27,920 --> 00:00:35,360
MySchool connector uses what's called a cursor in order to go back and forth between between in the

7
00:00:35,360 --> 00:00:35,770
database.

8
00:00:35,780 --> 00:00:41,660
If you open up the movie stable Python movies table in case we have movies and I don't have any movies,

9
00:00:41,660 --> 00:00:48,890
but we figure if we have many movies this, this might connector in order to get data.

10
00:00:48,890 --> 00:00:54,440
In order to get movies from the database, it's going to need to use what's called the cursor, and

11
00:00:54,440 --> 00:01:00,830
the cursor is going to allow it to go back and forth and get and fetch data from all our data from the

12
00:01:00,830 --> 00:01:01,250
database.

13
00:01:01,670 --> 00:01:03,850
So we need to create a cursor, we need to say.

14
00:01:04,870 --> 00:01:16,860
We need to create a new variable called my cursor cursor is equal to my database, the cursor cursor.

15
00:01:17,200 --> 00:01:17,530
Sarah.

16
00:01:18,700 --> 00:01:24,010
So this function is going to give you the cursor and this microscope is going to be used throughout

17
00:01:24,080 --> 00:01:29,380
the application to get and and do anything with it.

18
00:01:30,520 --> 00:01:33,520
So this is the first step which is creating cursor.

19
00:01:34,030 --> 00:01:42,760
The second step is that now in any function, we can use this cursor to execute anything we want and

20
00:01:42,760 --> 00:01:46,060
do all sorts of operations with a database.

21
00:01:46,510 --> 00:01:50,680
So the first thing that we need to do is that we need to get movies to get movies.

22
00:01:51,810 --> 00:01:57,240
We need to use the cursor, so here I'm going to say I'm going to say my cursor.

23
00:01:59,490 --> 00:02:07,570
And and they can use this microshare there, however, before using this cursor, we need to use my

24
00:02:07,570 --> 00:02:08,290
askew ill.

25
00:02:08,890 --> 00:02:11,690
So here we need to give you an excuse.

26
00:02:11,980 --> 00:02:16,720
Command that is going to get that's going to get all movies from a database.

27
00:02:17,350 --> 00:02:22,260
However, we don't have any movies in the rhetoric, so let's insert a few movies so lenient.

28
00:02:22,270 --> 00:02:23,190
There's a few movies here.

29
00:02:23,200 --> 00:02:28,080
I'm going to click on Insert, so I'm going to here, insert the first movie I'm going to say in Joker

30
00:02:28,750 --> 00:02:30,850
and then the year, let's say 20.

31
00:02:31,820 --> 00:02:34,600
Do we need to, for example, and then storyline?

32
00:02:36,170 --> 00:02:39,980
I'm going to keep it empty for now, and then I'm going to click on, go ahead.

33
00:02:40,070 --> 00:02:42,980
And this is going to serve the first movie, Whitson said another.

34
00:02:43,280 --> 00:02:44,930
A couple other movies on here.

35
00:02:44,930 --> 00:02:47,150
I'm going to say Batman.

36
00:02:49,230 --> 00:02:49,560
And.

37
00:03:08,230 --> 00:03:09,520
A Leaving Cert, another movie.

38
00:03:18,420 --> 00:03:22,530
Let me do a man so that you see here, so here I'm going to insert.

39
00:03:52,530 --> 00:04:01,980
I'm going to insert a few movies, and after that, let me click on, go and live inside another one

40
00:04:01,980 --> 00:04:05,850
before I move on and listen, save this one as well.

41
00:04:12,080 --> 00:04:19,520
So I'm trying to be I'm trying to get everything correct because I don't want to insert fake names here.

42
00:04:20,600 --> 00:04:27,330
It's important to insert real names and real dates because you it's going to it's going to help you

43
00:04:27,330 --> 00:04:28,670
all in terms of learning.

44
00:04:32,560 --> 00:04:35,620
Let me click on Go, and now we have I think we have now for movies.

45
00:04:36,130 --> 00:04:39,130
So if you click on Browse, we have here four movies.

46
00:04:39,340 --> 00:04:40,390
So let's continue now.

47
00:04:41,140 --> 00:04:47,350
Now what I'm going to do is that in order to get the movies, we need to use this skill and the skill

48
00:04:47,350 --> 00:04:50,740
command to get movies is select all from.

49
00:04:51,010 --> 00:04:55,300
And then the name of the the name of the table.

50
00:04:55,570 --> 00:04:59,830
So here I'm going to create a variable called scale that is equal to.

51
00:05:00,190 --> 00:05:01,700
And by the way, this is not python.

52
00:05:01,720 --> 00:05:02,740
This is a skill.

53
00:05:03,190 --> 00:05:05,740
So don't worry if you don't understand this, I'm going to explain this.

54
00:05:06,160 --> 00:05:10,450
This is called a skill in language, and it's by the way, it's very, very simple.

55
00:05:10,810 --> 00:05:11,860
It's like English.

56
00:05:11,860 --> 00:05:16,510
It's like you are if you are reading or writing English.

57
00:05:17,140 --> 00:05:24,790
So here we do say in order to get everything we need to say, select, select and then all all, in

58
00:05:24,790 --> 00:05:26,620
order to get everything, we use asterisk.

59
00:05:27,100 --> 00:05:31,830
So we need to say select all from from.

60
00:05:32,380 --> 00:05:34,450
And then the name of the name of the table.

61
00:05:34,720 --> 00:05:36,190
So what is the name of the table?

62
00:05:36,550 --> 00:05:38,350
The name of the table is movies.

63
00:05:39,160 --> 00:05:41,350
As you can see, the command is even written here.

64
00:05:41,710 --> 00:05:43,180
Select all from movies.

65
00:05:43,870 --> 00:05:47,380
So here I'm going to say select all from movies.

66
00:05:48,550 --> 00:05:50,390
So this is the school command.

67
00:05:50,950 --> 00:05:54,060
Then we need to execute this command and to execute this command.

68
00:05:54,060 --> 00:05:55,160
Do we need to use the cursor?

69
00:05:55,180 --> 00:06:02,800
I'm going to say my cursor and then not execute, execute.

70
00:06:04,420 --> 00:06:08,350
And then this execute function takes basically a real command that you want to execute.

71
00:06:08,770 --> 00:06:10,600
So I'm going to ask you to get your command.

72
00:06:11,230 --> 00:06:12,400
And that's it.

73
00:06:12,430 --> 00:06:15,700
Now what we want to do is that we have to rescue this.

74
00:06:16,150 --> 00:06:21,960
We want to use the cursor to get everything from the right that has been written.

75
00:06:21,970 --> 00:06:25,600
So I'm going to say my cursor that.

76
00:06:26,660 --> 00:06:27,230
Which?

77
00:06:28,400 --> 00:06:36,380
Fitch or Fitch all is a function that would return everything that has been retained by the cursor.

78
00:06:36,830 --> 00:06:41,210
So this is going to be doing everything and then we can store it in a valuable gold movies.

79
00:06:41,240 --> 00:06:45,950
I'm going to say movies is equal to my cursor dot virtual.

80
00:06:46,250 --> 00:06:47,870
And then I'm going to return the movies.

81
00:06:48,320 --> 00:06:51,290
Let me now click on file and then save all, and let's test.

82
00:06:51,920 --> 00:06:57,180
Now, in order to test, we need to open up the the local horse.

83
00:06:57,330 --> 00:07:01,280
Just make sure that we look at is is up and running.

84
00:07:01,280 --> 00:07:05,420
So here, as you can see, my horse is up and running.

85
00:07:05,780 --> 00:07:08,660
Of course, I have taught you how to do this.

86
00:07:09,290 --> 00:07:10,250
Do again.

87
00:07:10,250 --> 00:07:18,470
If you want to run this over the look of hostility to use the you the unicorn main app, main goal,

88
00:07:18,470 --> 00:07:19,670
an app and then reload.

89
00:07:20,300 --> 00:07:20,660
I can.

90
00:07:20,660 --> 00:07:26,750
I can do that a lot, and this is going to start your server, which is one 20 seven zero zero one 8000.

91
00:07:27,320 --> 00:07:34,010
Now you need to go through one 27 zero zero one, going on eight thousand and then force ducks.

92
00:07:35,000 --> 00:07:37,250
Now, let me refresh this.

93
00:07:39,230 --> 00:07:39,890
And let's this.

94
00:07:41,470 --> 00:07:43,930
So what we want to this is that we want to test the movies.

95
00:07:44,620 --> 00:07:52,540
I'm going to click on movies and this now should return if I click on execute or try, try, try it

96
00:07:52,540 --> 00:07:54,220
out and then execute.

97
00:07:55,530 --> 00:08:00,160
As you can see, this is going to return all of the movies to their movies, that that will be written

98
00:08:00,180 --> 00:08:02,940
should be the movies that we have in the database.

99
00:08:03,300 --> 00:08:05,250
So what are the movies that we have in the database?

100
00:08:05,790 --> 00:08:07,350
We have Ice Age online.

101
00:08:07,860 --> 00:08:08,430
Let's try.

102
00:08:08,640 --> 00:08:09,510
Let's test this.

103
00:08:10,080 --> 00:08:12,090
So let's let's verify this here.

104
00:08:12,600 --> 00:08:15,510
The movies that have been written are Joker.

105
00:08:16,050 --> 00:08:21,090
Batman Begins, Ice Age and and Lion King.

106
00:08:21,210 --> 00:08:22,020
So this is correct.

107
00:08:22,770 --> 00:08:26,400
So I also want you to pay attention to the type of data that has been retained.

108
00:08:26,880 --> 00:08:29,400
The type of data that has been returned isn't today.

109
00:08:30,180 --> 00:08:31,890
It's an array of arrays.

110
00:08:32,250 --> 00:08:39,240
So it's a big gains small array where each single array return, where each single array represents

111
00:08:39,240 --> 00:08:39,660
a movie.

112
00:08:40,020 --> 00:08:44,850
So, for example, Joker is an array or a list.

113
00:08:44,850 --> 00:08:46,680
In Python, it's called a list.

114
00:08:47,220 --> 00:08:53,550
So we have here Joker, we have Batman Begins, etc. and each single one is stored in a list.
