1
00:00:03,710 --> 00:00:04,130
Okay.

2
00:00:04,130 --> 00:00:04,939
Let's continue.

3
00:00:04,939 --> 00:00:11,480
So if you remember we are working in the A building.

4
00:00:11,480 --> 00:00:17,510
We are building the back end of our basic, uh, level three application.

5
00:00:17,510 --> 00:00:22,520
And what we have done so far is the initial setup.

6
00:00:22,520 --> 00:00:29,600
We have created the virtual environment, we have installed the necessary packages, and then we have

7
00:00:29,600 --> 00:00:37,940
created the database, entered the credentials of the database in the dot m file and validate the data

8
00:00:37,940 --> 00:00:42,860
types of the uh, the credentials with pedantic.

9
00:00:43,190 --> 00:00:50,120
We are now going to create the table we are going to use in the database.

10
00:00:50,120 --> 00:00:59,780
So if you are not familiar with databases, um, don't worry about uh, about the concept of a database

11
00:00:59,780 --> 00:01:02,330
is it cannot be more simple.

12
00:01:02,930 --> 00:01:07,010
A database is just a collection of tables.

13
00:01:07,010 --> 00:01:14,600
And you already know a table because you have worked with spreadsheets and tables of columns and rows.

14
00:01:14,600 --> 00:01:15,080
So.

15
00:01:15,080 --> 00:01:20,720
So a database is just one table or a series of tables, you know.

16
00:01:20,720 --> 00:01:27,020
So in this case we are going to do the most simple type of a database, which is one database with just

17
00:01:27,020 --> 00:01:28,250
one table.

18
00:01:28,250 --> 00:01:28,880
Okay.

19
00:01:28,880 --> 00:01:31,550
So we already created the database.

20
00:01:31,550 --> 00:01:34,010
You remember when we did this.

21
00:01:34,160 --> 00:01:39,890
And we call the database my database in a very original manner.

22
00:01:39,890 --> 00:01:44,030
And now we are going to create the the table okay.

23
00:01:44,390 --> 00:01:49,280
So before that we check the local server.

24
00:01:49,340 --> 00:01:57,770
And uh right now well here we are providing you alternative ways to check the the server.

25
00:01:58,190 --> 00:01:59,480
Don't worry about this.

26
00:01:59,480 --> 00:02:02,510
Uh, now you can try this later.

27
00:02:02,510 --> 00:02:05,270
You know, these different approaches etc..

28
00:02:05,270 --> 00:02:06,350
So now.

29
00:02:07,070 --> 00:02:08,840
After the initial check.

30
00:02:08,990 --> 00:02:13,040
Now close the app and set the database migrations.

31
00:02:13,040 --> 00:02:16,670
When we say database migration is okay, we are going to create a table.

32
00:02:16,670 --> 00:02:17,210
Okay?

33
00:02:17,420 --> 00:02:27,560
So in order to close the backend server you have to use control C okay.

34
00:02:27,560 --> 00:02:34,460
So you press the key control and the key C at the same time control C boom.

35
00:02:34,460 --> 00:02:39,140
And you will see that in the terminal the server stops okay.

36
00:02:39,800 --> 00:02:47,150
So now we are going to write a some lines that are going to sound like Chinese to you.

37
00:02:47,150 --> 00:02:48,020
Don't worry.

38
00:02:48,020 --> 00:02:52,250
The main purpose of all these lines is to create a table.

39
00:02:52,250 --> 00:02:52,640
Okay.

40
00:02:52,640 --> 00:02:56,060
So we are going to use a package called Alembic.

41
00:02:56,060 --> 00:03:04,100
And here you have a detailed explanation of what Alembic does, what this, uh, instruction does,

42
00:03:04,100 --> 00:03:07,370
etc. but right now I'm not going to stop there.

43
00:03:07,370 --> 00:03:13,820
We are just going back to our code editor.

44
00:03:13,940 --> 00:03:23,630
And when you when you, uh, execute this in your terminal, the application is going to create this

45
00:03:23,630 --> 00:03:26,090
folder for you, the Alembic folder.

46
00:03:26,090 --> 00:03:33,890
And you as you can see, this is just a version control a device to check.

47
00:03:33,890 --> 00:03:37,430
You know what we are doing with our database okay.

48
00:03:37,430 --> 00:03:39,530
So you will see what happens here later.

49
00:03:39,860 --> 00:03:40,760
So.

50
00:03:41,760 --> 00:03:51,210
A the first thing we are going to do is we are going to introduce this little, uh, change in the M

51
00:03:51,210 --> 00:03:56,100
file MP file that Alembic has created for us here.

52
00:03:56,310 --> 00:04:06,090
So in order for, uh, Alembic to use the credentials of the database, we are going to, uh, include.

53
00:04:06,780 --> 00:04:09,270
These line, these config set.

54
00:04:09,270 --> 00:04:12,990
What we are telling here is telling okay.

55
00:04:12,990 --> 00:04:18,089
So you are going to use and the the database.

56
00:04:18,089 --> 00:04:22,740
We have a with this database user and database password.

57
00:04:22,740 --> 00:04:28,110
So we are telling it in order to know what are the credentials of the database, you will have to go

58
00:04:28,110 --> 00:04:30,210
to the main m file okay.

59
00:04:30,600 --> 00:04:39,030
So for Alembic to know where is this m file we are going to enter here import OS.

60
00:04:39,030 --> 00:04:44,460
And then from dot m import load dot m which is what we are telling you here.

61
00:04:44,460 --> 00:04:45,330
And load them.

62
00:04:45,330 --> 00:04:53,460
So this line, this line, this line and this line, the 18 line, which is very long as you can see,

63
00:04:53,460 --> 00:05:01,740
are the ones that we are telling you that you have to add to the default m dot pi that Alembic has created

64
00:05:01,740 --> 00:05:04,980
inside of the Alembic a folder.

65
00:05:05,280 --> 00:05:06,270
Not important.

66
00:05:06,270 --> 00:05:07,500
This is not important.

67
00:05:07,500 --> 00:05:08,160
Okay.

68
00:05:09,110 --> 00:05:12,770
And so just, uh, stay with me and get the concept, and that's it.

69
00:05:12,770 --> 00:05:20,330
So now we are going to create the table of our database, and we are going to call this table todos.

70
00:05:20,360 --> 00:05:21,110
Okay.

71
00:05:21,110 --> 00:05:30,890
So in order to create a table in the database called todos you enter this command in your terminal okay.

72
00:05:31,760 --> 00:05:36,200
And you will see after doing that you do these operations.

73
00:05:36,200 --> 00:05:41,300
My recommendation is that first you pay attention to the video.

74
00:05:41,540 --> 00:05:46,100
Second, you download the code from GitHub.

75
00:05:46,340 --> 00:05:54,440
Third, you a repeat these operations with a copy and paste.

76
00:05:54,440 --> 00:06:02,660
So you open a new folder and you start copying and pasting, you know, and the things in this exact

77
00:06:02,660 --> 00:06:03,410
order.

78
00:06:03,410 --> 00:06:08,990
Whenever you find a problem, a doubt, a question, you go to chat, GPT four and the different sources

79
00:06:08,990 --> 00:06:10,190
you have, okay.

80
00:06:10,610 --> 00:06:16,100
And you do that the times you need in order to get familiar with the main concepts.

81
00:06:16,930 --> 00:06:26,350
So when you create a table, you will see that in Alembic versions you are going to have a file like

82
00:06:26,350 --> 00:06:27,130
this one.

83
00:06:27,130 --> 00:06:33,640
That is just a way to acknowledge that you have created the table.

84
00:06:33,640 --> 00:06:41,770
And in this, uh, file we are going to introduce a few changes which are basically these lines here.

85
00:06:41,770 --> 00:06:42,280
Okay.

86
00:06:42,280 --> 00:06:48,430
It's just telling, uh, that what are the contents we are going to have in the table.

87
00:06:48,430 --> 00:06:54,430
So in this case, our table, each of the items, each of the tasks is going to have a name.

88
00:06:54,940 --> 00:07:01,480
It's going to have an ID and it's going to have a completed A.

89
00:07:02,490 --> 00:07:03,000
Element.

90
00:07:03,000 --> 00:07:03,360
Right?

91
00:07:03,360 --> 00:07:05,970
So the computer is going to be what we call a boolean.

92
00:07:05,970 --> 00:07:09,450
So a complete it can be true or false okay.

93
00:07:09,660 --> 00:07:11,670
So not very important.

94
00:07:11,670 --> 00:07:15,000
We are just configuring the database okay.

95
00:07:15,000 --> 00:07:23,460
So in order to uh execute it uh the migration is just a way to like okay.

96
00:07:23,460 --> 00:07:23,790
Yes.

97
00:07:23,790 --> 00:07:26,190
You have created the database and the table.

98
00:07:26,190 --> 00:07:26,700
Excellent.

99
00:07:26,700 --> 00:07:33,780
So in order to execute this we are going to open Postgres from uh, the terminal.

100
00:07:33,780 --> 00:07:38,220
We are going to open our database inside of Postgres.

101
00:07:38,220 --> 00:07:45,870
So this is like opening Postgres in your in your computer and opening this database in progress in Postgres.

102
00:07:45,870 --> 00:07:51,420
And then you are going to create a database user with this name.

103
00:07:51,420 --> 00:07:55,650
And with this password you can choose the name and the password you want.

104
00:07:55,650 --> 00:07:58,170
This is the ones we are using in this example.

105
00:07:58,170 --> 00:08:06,210
And you are going to tell Postgres that this user has has all privilege so it can do whatever it wants

106
00:08:06,210 --> 00:08:06,900
okay.

107
00:08:07,510 --> 00:08:13,960
So we are telling here, give the user with this name user 12 all privilege.

108
00:08:13,960 --> 00:08:20,590
So all all the permissions in order to do whatever he wants to do in the database, name my database

109
00:08:20,590 --> 00:08:21,130
okay.

110
00:08:21,130 --> 00:08:25,450
And then this is going to close Postgres in your terminal okay.

111
00:08:25,450 --> 00:08:27,820
Here you have an alternative way of doing this.

112
00:08:27,820 --> 00:08:29,140
But don't worry about that.

113
00:08:29,860 --> 00:08:33,580
Then you go to Alembic dot.

114
00:08:34,460 --> 00:08:35,000
Ini.

115
00:08:35,900 --> 00:08:41,000
Okay, alembic ini and you edit the line.

116
00:08:42,230 --> 00:08:43,760
64.

117
00:08:43,789 --> 00:08:44,390
Okay.

118
00:08:44,390 --> 00:08:51,800
This line you are going to edit with your username, your password and the name of your database.

119
00:08:51,800 --> 00:08:57,080
And in this case a we know this is a local database okay.

120
00:08:57,960 --> 00:09:03,330
So you are also going to edit the the main dot m file.

121
00:09:03,390 --> 00:09:08,520
Uh, in order to include your right user and right password.

122
00:09:08,730 --> 00:09:09,330
Okay.

123
00:09:11,120 --> 00:09:16,700
So now we have a the new table in our database.

124
00:09:16,700 --> 00:09:18,020
And in order to.

125
00:09:19,280 --> 00:09:20,270
Close the deal.

126
00:09:20,270 --> 00:09:24,740
We are going to run this, uh, command in terminal.

127
00:09:24,740 --> 00:09:25,190
Okay.

128
00:09:25,190 --> 00:09:27,200
Alembic, upgrade head boom.

129
00:09:27,200 --> 00:09:27,950
That's it.

130
00:09:28,310 --> 00:09:35,360
Then if you want to check the status of your data database in your terminal, you do this.

131
00:09:35,360 --> 00:09:43,430
What this is doing is like, okay, open this database and show me everything that is in the table called

132
00:09:43,430 --> 00:09:44,090
todos.

133
00:09:44,090 --> 00:09:44,630
Okay.

134
00:09:44,630 --> 00:09:45,170
That's it.

135
00:09:45,170 --> 00:09:46,910
And then quit close.

136
00:09:46,910 --> 00:09:47,510
Okay.

137
00:09:47,510 --> 00:09:48,950
Not important.

138
00:09:49,310 --> 00:09:53,120
We give you some some more details about that here.

139
00:09:53,120 --> 00:10:01,460
We are also telling you that there is another file called database.py that has the object relational

140
00:10:01,460 --> 00:10:10,550
mapping, which is more additional information to uh let the application know about the, the the database

141
00:10:10,550 --> 00:10:13,040
and how to use the database, etc., etc..

142
00:10:13,040 --> 00:10:13,970
Not important.

143
00:10:14,000 --> 00:10:14,690
Now.

144
00:10:14,690 --> 00:10:17,630
Models.py more the same.

145
00:10:18,440 --> 00:10:24,740
Uh, we are just, you know, configuring our database or go here in detail later.

146
00:10:24,740 --> 00:10:26,420
Now it's not important.

147
00:10:26,510 --> 00:10:36,440
What is important now is the most important file of the backend, uh, application, which is this Crud.

148
00:10:36,440 --> 00:10:45,650
In this Crud, we are going to write the Python functions to, uh, perform the main operations of our

149
00:10:45,650 --> 00:10:46,520
application.

150
00:10:46,520 --> 00:10:47,330
Okay.

151
00:10:48,500 --> 00:10:56,690
So here we are going to explain you in super detail everything that you see here.

152
00:10:56,960 --> 00:10:57,500
Okay.

153
00:10:57,500 --> 00:11:06,200
So every little piece of this code is super explained in this notebook okay.

154
00:11:06,200 --> 00:11:07,160
Super explain.

155
00:11:07,700 --> 00:11:08,210
Okay.

156
00:11:08,810 --> 00:11:15,230
Then we are explaining you the things you are going to do in the router.

157
00:11:15,350 --> 00:11:24,140
So the router is what is going to convert our Python application in a web application.

158
00:11:24,140 --> 00:11:31,040
Because the router manages the routes, the routes of the web applications, the different pages and

159
00:11:31,040 --> 00:11:32,030
the different actions.

160
00:11:32,030 --> 00:11:32,480
Okay.

161
00:11:32,480 --> 00:11:39,620
So all this code you have here is explained in detail in the notebook okay.

162
00:11:40,840 --> 00:11:50,530
So once you create the to DOS router, you will need to come back to the main file and uncomment this

163
00:11:50,530 --> 00:11:52,630
line and this line.

164
00:11:52,630 --> 00:11:54,070
Right now they are uncommented.

165
00:11:54,070 --> 00:11:55,060
They are okay.

166
00:11:55,060 --> 00:12:00,850
But before I told you to enter here a pound sign and the same here.

167
00:12:00,850 --> 00:12:08,410
Okay, now we have the router so we can clear the pound sign there and there okay.

168
00:12:08,890 --> 00:12:17,380
Then you can run the server again from the terminal with the same, uh, instruction.

169
00:12:17,800 --> 00:12:21,730
And you can you don't have a front end.

170
00:12:22,330 --> 00:12:24,430
So you cannot.

171
00:12:24,430 --> 00:12:33,280
Without a front end, the user cannot enter a task here or delete a task or update a task, but you

172
00:12:33,280 --> 00:12:39,340
from the back end using the terminal can perform this operation.

173
00:12:39,340 --> 00:12:48,100
So here you have how to try your graph application from your terminal.

174
00:12:48,100 --> 00:12:52,870
So this is what you need to write to create one.

175
00:12:52,870 --> 00:13:01,420
To do tasks from your terminal and to display, to update, to delete, etc., etc..

176
00:13:01,870 --> 00:13:12,220
Okay, so right now you have a very basic back end of a Crud application.

177
00:13:13,900 --> 00:13:17,020
I know a lot of new things.

178
00:13:17,020 --> 00:13:18,280
Uh, here.

179
00:13:18,280 --> 00:13:21,700
Uh, do not feel overwhelmed.

180
00:13:21,760 --> 00:13:23,830
Just stay with me.

181
00:13:23,830 --> 00:13:24,880
Bear with me.

182
00:13:24,880 --> 00:13:34,090
Keep the main concepts and start repeating this subsection in the way I have recommended until you start

183
00:13:34,090 --> 00:13:35,740
feeling comfortable.

184
00:13:36,630 --> 00:13:41,250
Whenever you have a problem, whenever you have a question, whenever you have an error, while you

185
00:13:41,250 --> 00:13:43,860
are repeating this exercise, go to chat.

186
00:13:43,860 --> 00:13:46,830
GPT four and the other sources we have recommended.

187
00:13:46,830 --> 00:13:50,460
Okay, so download the code from GitHub.

188
00:13:50,790 --> 00:14:00,660
First, repeat the process once in your computer and then twice and third time, etc. etc. don't bother.

189
00:14:00,660 --> 00:14:06,870
Don't don't worry about creating many, uh, different folders for many different applications.

190
00:14:06,930 --> 00:14:13,410
Uh, just repeat this until you feel comfortable and whenever you find a problem, just investigate

191
00:14:13,410 --> 00:14:14,520
about it, okay?

192
00:14:14,520 --> 00:14:24,510
And once you feel a comfortable, then we go to create the front end of our application.

193
00:14:24,510 --> 00:14:24,990
Okay.

194
00:14:24,990 --> 00:14:27,420
It will be in the notebook.

195
00:14:28,960 --> 00:14:34,240
It will be what we call the part two, which is here.

196
00:14:34,330 --> 00:14:35,020
Okay.

197
00:14:35,020 --> 00:14:40,630
So in the next subsection we are going to create the front end of the application.

