0
1
00:00:04,540 --> 00:00:05,770
<v Volkan>Hello again, in this lecture</v>
1

2
00:00:05,770 --> 00:00:07,560
we are going to create our database,
2

3
00:00:07,560 --> 00:00:10,370
and also a new Python file for,
3

4
00:00:10,370 --> 00:00:13,130
let me run our application for My People, okay.
4

5
00:00:13,130 --> 00:00:15,080
So what I need to do, I need to create,
5

6
00:00:15,080 --> 00:00:20,070
I need to use here command property for my button, right?
6

7
00:00:20,070 --> 00:00:21,750
And then I click this button,
7

8
00:00:21,750 --> 00:00:24,790
I want to open a new window, okay.
8

9
00:00:24,790 --> 00:00:27,330
So how I will do that I need to create here
9

10
00:00:27,330 --> 00:00:30,580
firstly, a new Python file, okay?
10

11
00:00:30,580 --> 00:00:32,440
As I said, remember, I said,
11

12
00:00:32,440 --> 00:00:36,220
we are going to use multiple Python files, right?
12

13
00:00:36,220 --> 00:00:40,320
And our second Python file is here,
13

14
00:00:40,320 --> 00:00:43,350
will be new Python file, right.
14

15
00:00:43,350 --> 00:00:46,583
And for Python file I will say My People okay.
15

16
00:00:47,740 --> 00:00:52,030
This is our Python file and it's here.
16

17
00:00:52,030 --> 00:00:53,963
So how can I use it here,
17

18
00:00:56,490 --> 00:00:59,470
in my main.py file.
18

19
00:00:59,470 --> 00:01:02,870
Here we need to import our file first,
19

20
00:01:02,870 --> 00:01:07,870
and I will say here import mypeople okay.
20

21
00:01:07,900 --> 00:01:09,740
This is important if you don't import,
21

22
00:01:09,740 --> 00:01:11,700
you cannot use it here okay.
22

23
00:01:11,700 --> 00:01:14,670
I already imported my file alright, it's okay.
23

24
00:01:14,670 --> 00:01:17,170
So after it here what can I do?
24

25
00:01:17,170 --> 00:01:19,400
How can I open a new window?
25

26
00:01:19,400 --> 00:01:22,100
Actually there are two ways to do that.
26

27
00:01:22,100 --> 00:01:23,330
I will show both of them
27

28
00:01:23,330 --> 00:01:25,940
but I recommend this one, the first one
28

29
00:01:25,940 --> 00:01:29,390
and here for first button I will say here,
29

30
00:01:29,390 --> 00:01:32,180
after font property you know you say,
30

31
00:01:32,180 --> 00:01:37,023
command is equal to self.openMyPeople, okay.
31

32
00:01:41,290 --> 00:01:43,430
This is my function name okay.
32

33
00:01:43,430 --> 00:01:46,753
So let's copy this name and come here.
33

34
00:01:48,130 --> 00:01:50,240
What I need to do, I need to create my definition,
34

35
00:01:50,240 --> 00:01:54,712
My People and after it here what I will say
35

36
00:01:54,712 --> 00:01:58,359
now I need to create a instance right,
36

37
00:01:58,359 --> 00:02:01,340
an object from My People.
37

38
00:02:01,340 --> 00:02:03,543
So here I will say My People,
38

39
00:02:04,680 --> 00:02:07,380
not My People let's say something else maybe
39

40
00:02:09,493 --> 00:02:12,110
people or something like that okay.
40

41
00:02:12,110 --> 00:02:16,840
People is equal to this is very important.
41

42
00:02:16,840 --> 00:02:19,750
My People this is my Python file
42

43
00:02:19,750 --> 00:02:23,420
and second one must be my class name, okay.
43

44
00:02:23,420 --> 00:02:25,720
But we don't have any class yet so,
44

45
00:02:25,720 --> 00:02:28,920
let's firstly comment out this line
45

46
00:02:28,920 --> 00:02:32,620
and go to the My People dot py file here.
46

47
00:02:32,620 --> 00:02:35,880
What we need to do let's try to create it.
47

48
00:02:35,880 --> 00:02:38,380
I will say from tkinter,
48

49
00:02:38,380 --> 00:02:42,320
import asterisk everything and here
49

50
00:02:43,370 --> 00:02:44,800
now its enough for now.
50

51
00:02:44,800 --> 00:02:48,550
Let's create our class, class is
51

52
00:02:49,550 --> 00:02:53,820
it will be My People okay, the name of class
52

53
00:02:53,820 --> 00:02:58,640
and here I will inherit my class from top level okay.
53

54
00:02:58,640 --> 00:03:00,457
And after that here what I need to do,
54

55
00:03:00,457 --> 00:03:02,547
I need to say def init
55

56
00:03:08,682 --> 00:03:13,450
and here for parameter I will use only self okay,
56

57
00:03:13,450 --> 00:03:15,400
but after that I will say top level
57

58
00:03:17,291 --> 00:03:22,291
dot underscore underscore init again, okay.
58

59
00:03:22,520 --> 00:03:25,900
I will say again self here okay.
59

60
00:03:25,900 --> 00:03:30,040
And now I will create my geometry and title here.
60

61
00:03:30,040 --> 00:03:35,040
Self.geometry it will be 650 by 650
61

62
00:03:39,200 --> 00:03:44,200
and plus 620 and plus 200 okay,
62

63
00:03:45,670 --> 00:03:47,797
and after that what I will do,
63

64
00:03:47,797 --> 00:03:52,680
I will create a title, self.title
64

65
00:03:52,680 --> 00:03:55,360
by the way self means here itself, okay.
65

66
00:03:55,360 --> 00:03:59,210
My window okay that one, My People window,
66

67
00:03:59,210 --> 00:04:03,813
and after it here I will say for the title My People
67

68
00:04:06,730 --> 00:04:10,410
and for resizable I will say self.sizable
68

69
00:04:11,290 --> 00:04:13,550
and first parameter will be false
69

70
00:04:16,490 --> 00:04:19,450
and second one again false.
70

71
00:04:19,450 --> 00:04:21,290
Okay so maybe you might wonder
71

72
00:04:21,290 --> 00:04:24,110
why we don't use here root something like that
72

73
00:04:24,110 --> 00:04:29,110
because we are going to use main.py files main function.
73

74
00:04:31,530 --> 00:04:33,463
That's why we don't need to create here
74

75
00:04:33,463 --> 00:04:36,203
a main function for this file okay.
75

76
00:04:37,135 --> 00:04:41,253
Our main file is that one and that's why,
76

77
00:04:41,253 --> 00:04:44,690
we don't need to create a new main file.
77

78
00:04:44,690 --> 00:04:47,770
Of course you can create and it's not problem
78

79
00:04:47,770 --> 00:04:49,820
but you don't need it okay.
79

80
00:04:49,820 --> 00:04:52,500
And after that here what I need to do,
80

81
00:04:52,500 --> 00:04:56,650
now I already created my class right, it is also fine.
81

82
00:04:56,650 --> 00:05:01,023
So if I go here and,
82

83
00:05:04,540 --> 00:05:07,230
main right something's wrong.
83

84
00:05:07,230 --> 00:05:10,313
It is that one anyway so here what I want to do,
84

85
00:05:11,470 --> 00:05:13,550
I didn't say pass that's why.
85

86
00:05:13,550 --> 00:05:17,680
So now I will create my object, my instance, okay.
86

87
00:05:17,680 --> 00:05:21,490
People is equal to My People.
87

88
00:05:21,490 --> 00:05:25,620
This my Python file and after that my class name.
88

89
00:05:25,620 --> 00:05:29,632
My class name was My People
89

90
00:05:29,632 --> 00:05:33,640
and parentheses open and close parentheses, okay.
90

91
00:05:33,640 --> 00:05:35,500
This is important, don't forget it.
91

92
00:05:35,500 --> 00:05:38,470
Now we already created our instance okay,
92

93
00:05:38,470 --> 00:05:41,303
if I run my application now run.
93

94
00:05:42,480 --> 00:05:44,670
Now My People, right if I click My People,
94

95
00:05:44,670 --> 00:05:47,410
as you see now we have a new window okay,
95

96
00:05:47,410 --> 00:05:52,410
but we didn't create any design for our window, okay.
96

97
00:05:52,760 --> 00:05:54,010
It's totally empty.
97

98
00:05:54,010 --> 00:05:59,010
It has only title and also size and also location.
98

99
00:06:00,510 --> 00:06:04,450
Here okay we only created title and geometry
99

100
00:06:04,450 --> 00:06:06,990
and resizable false that's all.
100

101
00:06:06,990 --> 00:06:09,230
Okay so what we need to do now,
101

102
00:06:09,230 --> 00:06:13,300
we already created our also second window
102

103
00:06:13,300 --> 00:06:15,400
and now it's time to create our database.
103

104
00:06:15,400 --> 00:06:16,917
To create our database what we need to do,
104

105
00:06:16,917 --> 00:06:21,917
first you need to import import sqlite3 library okay,
105

106
00:06:24,520 --> 00:06:26,247
and after it here what I will say.
106

107
00:06:26,247 --> 00:06:30,040
I want to create connection cursor objects okay.
107

108
00:06:30,040 --> 00:06:31,690
For connection I will say con
108

109
00:06:31,690 --> 00:06:36,690
is equal to sqlite3.connect, okay.
109

110
00:06:36,870 --> 00:06:40,310
And here I nee to pass in my database name
110

111
00:06:40,310 --> 00:06:41,360
and to do that I will say
111

112
00:06:41,360 --> 00:06:46,360
database dot extension must be DB, okay.
112

113
00:06:46,670 --> 00:06:50,030
And the second thing here I nee to create my cursor object
113

114
00:06:50,030 --> 00:06:53,360
and I will say cur is equal to con,
114

115
00:06:53,360 --> 00:06:56,730
my connection object dot cursor, okay.
115

116
00:06:56,730 --> 00:07:00,010
And I don't need to pass in  any parameter for my cursor here.
116

117
00:07:00,010 --> 00:07:03,570
Now if I run my application, let's run it from main
117

118
00:07:03,570 --> 00:07:06,210
and we'll create our database.
118

119
00:07:06,210 --> 00:07:07,563
And if I say run,
119

120
00:07:09,580 --> 00:07:13,360
and now I'll click My People button My People.
120

121
00:07:13,360 --> 00:07:16,430
And now here pay attention here.
121

122
00:07:16,430 --> 00:07:17,770
Now as you see, here we go.
122

123
00:07:17,770 --> 00:07:19,690
Our database is here.
123

124
00:07:19,690 --> 00:07:23,380
So for our database, how I can edit my database to do that,
124

125
00:07:23,380 --> 00:07:27,360
I will not use here database SQL codes, okay.
125

126
00:07:27,360 --> 00:07:30,080
I don't want to do that because this is not easier way.
126

127
00:07:30,080 --> 00:07:31,070
We have an easier way to do that.
127

128
00:07:31,070 --> 00:07:34,220
What you need to do, we have a application here
128

129
00:07:34,220 --> 00:07:37,630
db browser for sqlite okay.
129

130
00:07:37,630 --> 00:07:38,520
This is the application name.
130

131
00:07:38,520 --> 00:07:43,480
It's very simple just Google it and it's official website.
131

132
00:07:43,480 --> 00:07:44,990
You can download the application
132

133
00:07:44,990 --> 00:07:47,910
and for installation steps is also very very simple.
133

134
00:07:47,910 --> 00:07:49,810
Just you'll say next next
134

135
00:07:49,810 --> 00:07:53,100
and you will make your installation for this application.
135

136
00:07:53,100 --> 00:07:54,924
Okay db browser for sqlite.
136

137
00:07:54,924 --> 00:07:57,860
So here what I need to do, I need to come here
137

138
00:07:57,860 --> 00:08:00,540
database db and I will say here
138

139
00:08:00,540 --> 00:08:03,163
right click show in explorer okay.
139

140
00:08:04,590 --> 00:08:06,380
My database is here now, right.
140

141
00:08:06,380 --> 00:08:09,060
And now I will click it.
141

142
00:08:09,060 --> 00:08:11,860
And as you see, now, my database is here
142

143
00:08:11,860 --> 00:08:12,860
and it's totally empty
143

144
00:08:12,860 --> 00:08:14,530
because we don't have any tables, right?
144

145
00:08:14,530 --> 00:08:17,867
It says table zero. So how can I create a table by the way,
145

146
00:08:17,867 --> 00:08:21,140
we are going to create only one single table, okay,
146

147
00:08:21,140 --> 00:08:23,110
for our application here.
147

148
00:08:23,110 --> 00:08:26,450
I will say for table name persons, okay.
148

149
00:08:26,450 --> 00:08:28,710
And after here I need to add fields
149

150
00:08:28,710 --> 00:08:33,320
for my table I will create six fields, okay.
150

151
00:08:33,320 --> 00:08:38,080
The first one is very important one, it will be person id.
151

152
00:08:38,080 --> 00:08:39,480
This is very important, okay.
152

153
00:08:39,480 --> 00:08:42,385
An id it must be integer.
153

154
00:08:42,385 --> 00:08:45,158
And after it here we have some options.
154

155
00:08:45,158 --> 00:08:49,810
The first one is auto increment okay, that one
155

156
00:08:49,810 --> 00:08:51,990
and the other one is primary key.
156

157
00:08:51,990 --> 00:08:56,650
So for id we have to set our id as,
157

158
00:08:56,650 --> 00:08:59,240
auto increment and primary key, okay.
158

159
00:08:59,240 --> 00:09:00,900
For other fields we don't need to do that.
159

160
00:09:00,900 --> 00:09:02,350
You can say not null.
160

161
00:09:02,350 --> 00:09:06,136
This is by the way not null let me enlarge it okay.
161

162
00:09:06,136 --> 00:09:09,270
We can set not null but of course we don't need it
162

163
00:09:09,270 --> 00:09:13,057
because for not null we will type our codes, okay.
163

164
00:09:13,057 --> 00:09:16,040
For the second field I will say for the field name,
164

165
00:09:16,040 --> 00:09:21,040
person name and it will be text okay
165

166
00:09:22,390 --> 00:09:27,390
and other one will be person surname, again text.
166

167
00:09:31,220 --> 00:09:36,220
After that person email.
167

168
00:09:36,240 --> 00:09:39,380
I think yes email and again text
168

169
00:09:40,870 --> 00:09:44,437
and after email I will say person phone okay
169

170
00:09:46,800 --> 00:09:51,800
and again text and the last one will be person address okay.
170

171
00:09:52,260 --> 00:09:57,260
Person address and that one is going to, text too.
171

172
00:09:57,330 --> 00:09:59,313
Okay, now after that I will say okay.
172

173
00:09:59,313 --> 00:10:02,240
Now something important here you need to say here,
173

174
00:10:02,240 --> 00:10:04,120
write changes okay.
174

175
00:10:04,120 --> 00:10:06,510
If you don't click write changes button,
175

176
00:10:06,510 --> 00:10:10,373
you will not execute these codes okay these codes.
176

177
00:10:11,600 --> 00:10:14,320
And now we create our table
177

178
00:10:14,320 --> 00:10:16,370
and after that what we need to do,
178

179
00:10:16,370 --> 00:10:19,767
actually this lesson is fine, its enough.
179

180
00:10:19,767 --> 00:10:22,490
In next lesson we are going to learn
180

181
00:10:22,490 --> 00:10:26,340
how we can fill, how we can create this add people
181

182
00:10:27,190 --> 00:10:29,370
because we need to make design for this guy.
182

183
00:10:29,370 --> 00:10:31,196
Okay and it will be next lesson.
183

184
00:10:31,196 --> 00:10:33,523
For now that's all, see you next.
