1
00:00:00,480 --> 00:00:01,260
Hello, everyone.

2
00:00:01,570 --> 00:00:08,790
Today we show you how you can insert a picture or picture in your database, so the first thing that

3
00:00:08,790 --> 00:00:11,720
you have to do is to create the database first.

4
00:00:11,970 --> 00:00:13,110
So we will give it.

5
00:00:13,320 --> 00:00:23,880
For example, we will import the library, which which is import as like a skylight tree as DB, for

6
00:00:23,880 --> 00:00:25,500
example, for like database.

7
00:00:25,890 --> 00:00:27,910
So here we have imported the library.

8
00:00:28,290 --> 00:00:31,690
Now we will really connect the database or recreate it.

9
00:00:31,920 --> 00:00:34,530
So as you can see here, we have already a database.

10
00:00:34,530 --> 00:00:42,870
So I will just connected the I will give it the name data base.

11
00:00:43,080 --> 00:00:57,360
Ekwall Beeby does connect and he will write the name, which is name the photo that if if you don't

12
00:00:57,360 --> 00:01:02,700
have the database you can write just this one, for example, is we create a new one for you.

13
00:01:03,210 --> 00:01:15,840
So we will make its database that commit to close its database that goes no.

14
00:01:15,990 --> 00:01:17,460
We will write the first.

15
00:01:17,460 --> 00:01:20,450
The first thing that we have to do is to import the picture.

16
00:01:20,700 --> 00:01:25,130
After that, we will put it or insert in the database.

17
00:01:25,440 --> 00:01:31,830
So before that, we will import the picture first and I will show you how to make the list to recreate

18
00:01:31,830 --> 00:01:40,860
the cursor first so he will make his cursor a cous cous cous are equal.

19
00:01:41,490 --> 00:01:50,250
Then here we have a database database that person now here we have the cursor, we have created the

20
00:01:50,250 --> 00:01:50,900
cursor here.

21
00:01:51,300 --> 00:01:56,820
No we will, we can import the picture after, after that we create a picture to get into the cursor.

22
00:01:56,820 --> 00:01:58,200
But I prefer to do this.

23
00:01:58,590 --> 00:02:06,000
So to political to to bring the picture we have to use this function which is really open.

24
00:02:06,210 --> 00:02:15,840
So with open now here we will write the path or if we have the picture already in the same same folder

25
00:02:15,840 --> 00:02:19,990
of our project, we will just need to type the name of the picture.

26
00:02:20,370 --> 00:02:21,690
So I will take this one.

27
00:02:21,690 --> 00:02:23,100
For example, this is the picture.

28
00:02:24,100 --> 00:02:29,220
So we will give it here for as names, which is new picture.

29
00:02:29,220 --> 00:02:33,690
And that's being so this function has two variables.

30
00:02:33,990 --> 00:02:39,140
The first two two parameters, sorry, the first parameter is the path or the name of the picture.

31
00:02:39,600 --> 00:02:46,140
Then the second second parameter, which is if we are if you in this case, we want to read a picture,

32
00:02:46,260 --> 00:02:50,800
if we want to bring it into the program and you convert it.

33
00:02:51,030 --> 00:02:58,110
So if we want to put or insert a picture into the database, we can't do it with any type of what we

34
00:02:58,110 --> 00:02:59,780
have to put it in the binary type.

35
00:03:00,090 --> 00:03:04,150
So to do this for this, we are using this function to convert the picture.

36
00:03:04,590 --> 00:03:09,250
So here we will write and be added for right.

37
00:03:09,360 --> 00:03:10,860
Me for binary.

38
00:03:10,860 --> 00:03:13,740
So it will write this picture as a binary.

39
00:03:14,040 --> 00:03:18,320
So here will make it as this is the syntax of dysfunction.

40
00:03:18,330 --> 00:03:26,460
So we write binary as for example, we make the given the name big, that equals here we get the name

41
00:03:26,460 --> 00:03:27,270
of the picture.

42
00:03:27,550 --> 00:03:32,100
This variable will take the value of our picture in the binary type.

43
00:03:32,370 --> 00:03:37,110
So here we have picture equal be that read.

44
00:03:38,220 --> 00:03:40,160
No, if we print this picture.

45
00:03:40,950 --> 00:03:44,760
So not this one print.

46
00:03:44,760 --> 00:03:52,180
If we print this picture, you will see this one, you will see that it is in the any time.

47
00:03:52,230 --> 00:03:53,990
As you can see, it is too long.

48
00:03:54,000 --> 00:03:56,100
I can chew on it, all of it.

49
00:03:56,400 --> 00:03:59,400
But you can see that this is the binary type of our picture.

50
00:03:59,970 --> 00:04:04,700
No, after that we import it, we have just to insert it to the database.

51
00:04:05,130 --> 00:04:08,100
Now we will create a table in the database.

52
00:04:08,100 --> 00:04:13,640
So cursor that executes No one.

53
00:04:13,860 --> 00:04:20,110
No, we will write create as always, table no.

54
00:04:20,120 --> 00:04:29,070
Now if we in the last in class with you or in the left in the video is talking about the database I

55
00:04:29,070 --> 00:04:37,140
have shown you, I told you that if we have a table with the name, we can put two tables in the same

56
00:04:37,140 --> 00:04:38,820
database with the same name.

57
00:04:38,820 --> 00:04:39,140
Sorry.

58
00:04:39,630 --> 00:04:41,280
So it is the same thing here.

59
00:04:41,280 --> 00:04:44,490
But there is we can solve it with another thing.

60
00:04:44,500 --> 00:04:51,120
So before that, because in this case, for example, to create a database, if we have already a name

61
00:04:51,990 --> 00:04:58,490
with this name, there is no problem because if we just connected so same thing here, we will create

62
00:04:58,500 --> 00:04:59,460
a table if.

63
00:05:00,810 --> 00:05:09,930
So if not exists, if this table that we will create is not exist, created, but exist, we would just

64
00:05:09,930 --> 00:05:13,960
because we will just put on it and work on it.

65
00:05:14,400 --> 00:05:17,300
So here we have created what if not exist?

66
00:05:17,610 --> 00:05:23,760
No, we will write the name of the table, which is, for example, we will give it the name and then

67
00:05:23,970 --> 00:05:26,290
B and for name and B for photos.

68
00:05:26,790 --> 00:05:30,150
So this is the bodices and he will write the parameters that we have.

69
00:05:30,150 --> 00:05:35,510
The first parameter is the name which with the date, the type text.

70
00:05:35,970 --> 00:05:41,790
Then the second parameter is the the photo with the type blobbed.

71
00:05:43,050 --> 00:05:45,320
This type is for the binary pictures.

72
00:05:45,330 --> 00:05:51,510
If we don't have a picture in the binary type, we can't use this one and we can't put it in the in

73
00:05:51,510 --> 00:05:53,080
the database.

74
00:05:53,430 --> 00:05:56,210
So in this one we have created the table.

75
00:05:56,550 --> 00:05:58,070
You will see that there is no arrows.

76
00:05:58,470 --> 00:06:03,550
No to ensure to see that we have really created this table.

77
00:06:03,930 --> 00:06:07,760
There is this one database, which is not this one.

78
00:06:08,070 --> 00:06:10,200
It's a base browser.

79
00:06:11,130 --> 00:06:15,510
We would see here file that we will open its.

80
00:06:17,510 --> 00:06:19,850
We see where is it, where is it?

81
00:06:21,800 --> 00:06:32,240
With the a.k.a., you know, this one, what is this one name for you and you will see that we have

82
00:06:32,240 --> 00:06:33,960
this table and this is the table.

83
00:06:33,980 --> 00:06:34,920
This is the database.

84
00:06:35,300 --> 00:06:36,050
This is the table.

85
00:06:36,050 --> 00:06:37,330
And B, that we have created.

86
00:06:37,580 --> 00:06:41,260
This is the color of images and this is the photos.

87
00:06:41,600 --> 00:06:46,880
So as you can see, we have created this the table inside this database.

88
00:06:47,300 --> 00:06:48,600
And we have two columns.

89
00:06:48,620 --> 00:06:51,710
The first is for the name and the second one is for the picture.

90
00:06:52,350 --> 00:06:59,120
Now, what we have to do is just to ensure this picture in the table, as we did with the text.

91
00:06:59,300 --> 00:07:01,420
And it is the same thing here.

92
00:07:01,610 --> 00:07:02,730
Nothing will change.

93
00:07:02,850 --> 00:07:03,370
We change.

94
00:07:03,740 --> 00:07:08,760
So we will make sure that we execute the same function.

95
00:07:09,020 --> 00:07:20,660
And here we will write, insert, not insert, insert that into the name of the table, which is and

96
00:07:20,660 --> 00:07:32,030
then be for photo, then values insurers in the table into the table and be the values which is this

97
00:07:32,030 --> 00:07:32,360
one.

98
00:07:32,420 --> 00:07:33,890
We will put it here.

99
00:07:33,890 --> 00:07:36,920
We have the first the first value which is the name.

100
00:07:36,920 --> 00:07:42,280
So I will put it like this name then the second one is the photo.

101
00:07:43,130 --> 00:07:45,080
As I told you, we can't change these names.

102
00:07:45,110 --> 00:07:48,800
It is not necessary to make it in the same same name.

103
00:07:48,810 --> 00:07:50,410
All of this, again, changes.

104
00:07:50,420 --> 00:07:54,260
But in this case, I want I prefer to make it in the same thing.

105
00:07:54,450 --> 00:07:57,640
OK, now we have this one and this one we have.

106
00:07:57,650 --> 00:08:01,460
And after that we have just to put the data in the database.

107
00:08:01,460 --> 00:08:03,540
So we have come on here, as we did before.

108
00:08:03,950 --> 00:08:07,330
Now we will open the brackets with this one.

109
00:08:07,730 --> 00:08:10,280
Now, once we have the first thing is the name.

110
00:08:10,700 --> 00:08:14,900
So name then column here we will have we will make a name, for example.

111
00:08:14,900 --> 00:08:22,450
I will give it like this, then come out after this will post the picture, which is photo equal.

112
00:08:22,880 --> 00:08:24,640
The picture that we have is this one.

113
00:08:24,650 --> 00:08:25,570
So we will write it.

114
00:08:25,580 --> 00:08:27,380
Just take one just like this.

115
00:08:27,380 --> 00:08:27,790
Sorry.

116
00:08:28,190 --> 00:08:29,480
Here we have the picture.

117
00:08:29,900 --> 00:08:31,820
So we have put it the name and the picture.

118
00:08:31,820 --> 00:08:41,840
If we run the program, you will see that there is no error and we will go to OK, here we have this

119
00:08:41,840 --> 00:08:45,080
one, as you can see.

120
00:08:45,080 --> 00:08:54,110
What is I what I can see it's this one picture and there's this one.

121
00:08:54,380 --> 00:08:59,030
As you can see, we can't see a picture because it is in the binary, as you can see, we can't see

122
00:08:59,030 --> 00:08:59,180
it.

123
00:08:59,210 --> 00:09:03,230
It is in Finnish here, but you can't see the picture because independently.

124
00:09:03,230 --> 00:09:10,250
But you can see here, you can see the the size of the picture, which is where this is too long to

125
00:09:10,250 --> 00:09:10,660
read it.

126
00:09:10,820 --> 00:09:17,690
So if we want to see if this picture is the same of this one, we would just see the size of the picture

127
00:09:17,690 --> 00:09:18,410
that we have here.

128
00:09:18,410 --> 00:09:20,810
And you will see that it is the same thing of this one.

129
00:09:21,290 --> 00:09:26,240
And the name, as you can see here, the name that we have put in here, you have Putsy here.

130
00:09:26,240 --> 00:09:28,350
We have the name, I mean, and same thing here.

131
00:09:28,790 --> 00:09:30,020
So that was for today.

132
00:09:30,020 --> 00:09:32,190
How to insert a picture in your face.

133
00:09:32,300 --> 00:09:39,140
As you can see, it is too easy to do it in the next video showing how we can select or how we can return

134
00:09:39,140 --> 00:09:40,780
the picture from the database.

135
00:09:41,060 --> 00:09:42,770
So that was for today.

136
00:09:42,770 --> 00:09:44,270
And I see you again.

137
00:09:44,750 --> 00:09:45,800
Stay safe by.
