1 00:00:00,810 --> 00:00:02,890 Hello, friends, in this video. 2 00:00:03,510 --> 00:00:10,260 I'll explain to you how to use the flask as kill alchemy extension in our last application. 3 00:00:16,140 --> 00:00:23,550 Most of the programming languages, especially the the ones that are very popular, like like Java or 4 00:00:23,550 --> 00:00:33,450 even Python or dot net languages, etc., they are object oriented in nature, whereas the database 5 00:00:33,460 --> 00:00:41,670 software that you use as a back end to the programs or applications written in these languages are the 6 00:00:41,670 --> 00:00:45,420 data is stored in the tables and the tables are sort of flat files. 7 00:00:46,370 --> 00:00:55,890 So on one hand, the programming language has class or it is object oriented and the database servers, 8 00:00:56,540 --> 00:01:00,610 the data is still in the form of tables, which are nothing but flat files. 9 00:01:01,190 --> 00:01:03,890 So the object lesson mapping technique. 10 00:01:04,830 --> 00:01:12,330 Is used to map the object parameters of a class to the underlying RDBMS table structure. 11 00:01:12,720 --> 00:01:15,630 So what do you have to do at the end of the day? 12 00:01:15,660 --> 00:01:23,360 The table has the fields, which are nothing but the instance which are equivalent to the instance variables 13 00:01:23,370 --> 00:01:24,040 of a class. 14 00:01:24,600 --> 00:01:35,970 So therefore, to map or to correlate the instance variables of a class to the fields in a table, that 15 00:01:35,970 --> 00:01:38,820 is how the object relation mapping is done. 16 00:01:40,060 --> 00:01:45,330 So it is a technique of mapping the object parameters to the table structure. 17 00:01:47,000 --> 00:01:57,560 In order to do that or any Aughrim API object relation mapping API provides the methods to perform the 18 00:01:57,740 --> 00:02:03,190 crude operation, you operations are done on any database table. 19 00:02:03,800 --> 00:02:11,510 So those database applications are operations like insert, delete, update, select, etc. These operations, 20 00:02:11,720 --> 00:02:22,220 rather than doing through a raw as Google query or command insert into a are set equal to insert from 21 00:02:22,670 --> 00:02:24,050 select start, etc.. 22 00:02:24,200 --> 00:02:30,860 All these skill statement instead of the programmer or the developer being required to execute these 23 00:02:30,860 --> 00:02:37,670 Ryosuke statements, he can now use his object oriented programming knowledge to perform all these activities 24 00:02:37,670 --> 00:02:39,600 using the OR MEPA. 25 00:02:40,310 --> 00:02:49,880 Ezekial Alchemy is a very popular tool kit for object relational relational mapping for python related 26 00:02:50,780 --> 00:02:51,940 projects or programs. 27 00:02:52,550 --> 00:03:01,850 So it is the object relational mapper that presents all the mechanism for Python related database handling. 28 00:03:03,230 --> 00:03:04,160 Eskil Alchemy. 29 00:03:04,160 --> 00:03:11,300 Can we use, along with different database servers like it can be used with Oracle, MySQL as Kuli, 30 00:03:11,510 --> 00:03:16,880 etc. flask Eskil alchemy is what it is. 31 00:03:16,880 --> 00:03:25,430 An extension to the you can add it to the flask set up our environment which adds the Eskil alchemy 32 00:03:25,430 --> 00:03:27,000 support to your flask application. 33 00:03:27,560 --> 00:03:31,010 So this is what is an object. 34 00:03:31,010 --> 00:03:40,970 Relational relation mapping and the use of flask is still alchemy will enable Aughrim into your flask 35 00:03:41,030 --> 00:03:41,570 application. 36 00:03:45,280 --> 00:03:51,160 So obviously, you will have to install the extension by using the. 37 00:03:52,860 --> 00:03:56,460 Utility people install Gaskill Alchemy will install it. 38 00:03:58,090 --> 00:04:04,390 In order to use the facilities, you are being Ezekial Alchemy class from this model. 39 00:04:05,590 --> 00:04:09,580 Statemented from Laskoski, Alchemy, Import, Eskil Alchemy. 40 00:04:10,620 --> 00:04:18,300 That is the mandatory step that you must do then in the application object configuration of the application 41 00:04:18,300 --> 00:04:27,840 object of your application, if the name of the object is Eppy Epilog config, specify the database. 42 00:04:27,840 --> 00:04:30,080 You are a ESKIL Alchemy database. 43 00:04:30,090 --> 00:04:37,680 You are right is equal to which database you are going to use if you like students as to like three, 44 00:04:37,950 --> 00:04:44,490 if the student is the name of the database that you are going to use, not object of this obscure alchemy 45 00:04:44,490 --> 00:04:45,030 class. 46 00:04:46,550 --> 00:04:53,420 Object of this Eskil Alchemy class, which you have imported, it will have all the helper functions 47 00:04:53,420 --> 00:04:56,270 for performing the wartime operations. 48 00:04:57,680 --> 00:05:01,790 It also provides provides what, the Eskil Alchemy class. 49 00:05:01,820 --> 00:05:12,110 It also provides a model class which should be used as the parent for defining the model of our corresponding 50 00:05:12,110 --> 00:05:15,060 to each table in your database. 51 00:05:16,130 --> 00:05:26,390 So in order to handle or process the data in the tables, you have to define an equivalent class based 52 00:05:26,390 --> 00:05:34,620 upon the model class, which refers to or which is corresponding to the table in your school database. 53 00:05:34,970 --> 00:05:38,600 Each model class corresponds to the table in the database. 54 00:05:38,960 --> 00:05:44,190 So, for example, if in the student's database student data is collected, there is a student stable. 55 00:05:44,870 --> 00:05:45,800 What do you do? 56 00:05:45,830 --> 00:05:51,670 You learn to define a class called a student, which will be based upon the baby daughter model. 57 00:05:54,800 --> 00:06:00,220 That is the first create an object of alchemy class. 58 00:06:00,740 --> 00:06:08,750 It requires the flask application object as the parameter that is the name of the Eskil Alchemy class 59 00:06:09,860 --> 00:06:14,660 using their Demiraj model as the pattern defines the class to the students. 60 00:06:14,660 --> 00:06:16,400 Is the name of the table in the. 61 00:06:17,680 --> 00:06:25,990 In our database, they will find all the corresponding fields, the instance variables corresponding 62 00:06:25,990 --> 00:06:34,750 to the fields in the in our table for the column name city address Pinkel. 63 00:06:35,820 --> 00:06:41,650 Additionally, I have to find a primary kilson so identical to the broad column. 64 00:06:43,180 --> 00:06:45,580 It is the name of the field, which is the primary. 65 00:06:45,730 --> 00:06:46,750 It will be an integer. 66 00:06:47,140 --> 00:06:53,320 So that string is used as the database for all these fields as you can expect. 67 00:06:53,320 --> 00:06:55,630 Name city address Pincott all will strings. 68 00:06:56,470 --> 00:06:57,000 So. 69 00:06:57,630 --> 00:07:01,000 So this is the declaration of the table structure. 70 00:07:03,020 --> 00:07:07,640 Each instance variable corresponding to the food in your table. 71 00:07:08,940 --> 00:07:16,250 OK, now, if you create the object of this student's class, obviously what is going to happen is constructor 72 00:07:16,260 --> 00:07:18,690 will execute the name of the constructor. 73 00:07:18,730 --> 00:07:26,910 They it the constructor will provide for Parramatta's name city address in those four parameters will 74 00:07:26,910 --> 00:07:34,740 be used to initialize these, for instance, variables, names, self, not names and address. 75 00:07:34,740 --> 00:07:36,990 And so this will be initialize. 76 00:07:36,990 --> 00:07:38,310 The object will be created. 77 00:07:38,790 --> 00:07:42,540 When the object will be created, that object will be used. 78 00:07:44,020 --> 00:07:50,250 For further processing, now that the model is declared, now first the table, the database is in place. 79 00:07:50,590 --> 00:07:51,680 The table is there. 80 00:07:52,210 --> 00:07:53,560 The model is created. 81 00:07:53,890 --> 00:07:54,820 All these. 82 00:07:56,690 --> 00:08:03,890 Database related activity to create or use the database mentioned in the you are right and create the 83 00:08:03,890 --> 00:08:06,360 tables executed to create all function. 84 00:08:06,770 --> 00:08:12,500 So this will not create all will is the table in the database and the table are not present. 85 00:08:12,530 --> 00:08:13,460 They will be created. 86 00:08:14,730 --> 00:08:21,310 And if they are present, they will be used, it is excellent to use a particular database kind of statement 87 00:08:21,530 --> 00:08:25,770 in our Escalade or any obscure military database. 88 00:08:30,030 --> 00:08:37,380 To this DBI object, there isn't such an object, bewildered session. 89 00:08:38,820 --> 00:08:48,470 So this session is a lot of time to the database, all the activities like insert the record, delete 90 00:08:48,480 --> 00:08:54,420 a record updated record, etc., they have to be done with the help for this session session object 91 00:08:54,430 --> 00:08:59,400 submittals, what is this about and what is to be added? 92 00:08:59,880 --> 00:09:06,600 What if the object of the student's class is created, the model class is created, the object will 93 00:09:06,600 --> 00:09:09,060 be used as an argument to this add function. 94 00:09:09,220 --> 00:09:15,290 So did not add the name of the object of the model class. 95 00:09:15,990 --> 00:09:21,780 Insert the record into the map table because your model is now mapping the table in your database. 96 00:09:21,780 --> 00:09:27,890 So therefore this and ultimately will add a record into the table. 97 00:09:28,980 --> 00:09:29,390 Okay. 98 00:09:30,480 --> 00:09:39,750 Similarly, the big decision to delete the name of the object model, what happens, the maverick label 99 00:09:39,750 --> 00:09:46,530 from the maverick label, this particular object or that this particular role will be deleted from the 100 00:09:46,530 --> 00:09:57,110 table, not in order to emulate the select committee, you are to set model, not query, not all in 101 00:09:57,120 --> 00:10:01,730 our guest students, students in the name of the modern model, not very good at all. 102 00:10:03,240 --> 00:10:10,020 Will it be equivalent to the select star from students so it will retrieve all the records from the 103 00:10:10,050 --> 00:10:16,620 underlying table, in this case the underlying Kabbalist student, so it is equal to select staff from 104 00:10:16,620 --> 00:10:17,160 students? 105 00:10:18,180 --> 00:10:24,510 OK, if you want to apply, remember, in the in the select committee, there is a very select start 106 00:10:24,510 --> 00:10:27,150 from students where models are greater than something. 107 00:10:27,840 --> 00:10:35,730 So if you want to apply a filter, you can use the filter option model or filter, whichever the condition 108 00:10:35,730 --> 00:10:36,140 you want. 109 00:10:36,870 --> 00:10:41,420 You can apply a filter to the written record that many number of records will be treated. 110 00:10:42,060 --> 00:10:44,640 Students start to filter by it. 111 00:10:46,110 --> 00:10:47,610 This is the condition, not all. 112 00:10:48,030 --> 00:10:52,590 So what happens from the records that are retrieved? 113 00:10:53,040 --> 00:10:58,170 Only those records in which it is equal to Hyderabad will be selected. 114 00:10:59,730 --> 00:11:00,210 OK. 115 00:11:04,630 --> 00:11:17,080 Now, this is the form in which there is a provision to enter the deadline to for taxpayers, for example, 116 00:11:18,130 --> 00:11:21,640 name, name, either having a tax free. 117 00:11:23,970 --> 00:11:30,520 Then email is having a TextField City PIN code, etc., and then there is a submit button, right? 118 00:11:30,990 --> 00:11:33,210 This is a simple, legible form, nothing else. 119 00:11:33,750 --> 00:11:37,380 And then the submit button will take the data back to the. 120 00:11:38,690 --> 00:11:41,840 Request, but from which the request was generated. 121 00:11:43,190 --> 00:11:51,380 OK, so when the request is when for the first time, when the form will be open, that will be a matter 122 00:11:51,620 --> 00:11:52,840 when it will be posted. 123 00:11:54,540 --> 00:12:03,060 The you will be visited with the help of the post method, in which case all the data posted by this 124 00:12:03,060 --> 00:12:11,610 form will be extracted by request or form to collect all that data request, not form, name, name, 125 00:12:11,610 --> 00:12:13,340 city PIN code and address. 126 00:12:13,680 --> 00:12:22,230 Use that data as the argument for the object of the student's class student is equal to students Euphorbia 127 00:12:22,250 --> 00:12:23,520 because the object will be created. 128 00:12:24,180 --> 00:12:31,800 Use that object to add the record into the underlying activity so user Demiraj should not add student. 129 00:12:33,330 --> 00:12:40,020 The data will be added and then finalize or commit the transaction by saying that they should not coming. 130 00:12:40,410 --> 00:12:48,630 So this is all the activity that are required to perform the insert operation equivalent insert operation. 131 00:12:50,460 --> 00:12:58,520 School has an insert, so the corresponding operation in order mapper is like this, right? 132 00:13:02,780 --> 00:13:12,680 And if you want to perform the select operation, then for that purpose, assure all of you function 133 00:13:12,680 --> 00:13:21,410 has been defined, which will render issue all template and what it will do, it will send the parameter 134 00:13:21,410 --> 00:13:24,010 as students equal to students. 135 00:13:24,020 --> 00:13:25,310 Don't worry at all. 136 00:13:26,180 --> 00:13:30,630 You'll see that model, dot, dot, all will retrieve all the records. 137 00:13:31,250 --> 00:13:34,580 Those records will be stored in a student's parameter. 138 00:13:34,970 --> 00:13:37,000 Essentially, this is a dictionary object. 139 00:13:37,310 --> 00:13:43,330 So from that dictionary object on each of who perform this to render a table. 140 00:13:43,340 --> 00:13:50,480 So at the end of the activity, you'll find a table being rendered on the browser with names of the 141 00:13:50,480 --> 00:13:53,500 fields and the values being displayed in tablas. 142 00:13:54,140 --> 00:14:03,650 So this is the entire sequence of events that, you know, is present in this interactivity, that it 143 00:14:03,650 --> 00:14:04,310 will be a form. 144 00:14:04,760 --> 00:14:08,810 The form will be posted to a view function. 145 00:14:08,810 --> 00:14:16,190 The view function will fetch the data and perform the add or insert operation. 146 00:14:16,700 --> 00:14:25,610 On the other hand, there will be equal and select operation which will find this very, very dot all 147 00:14:26,000 --> 00:14:29,470 sender data to the template. 148 00:14:29,720 --> 00:14:35,820 And this ginge to template code will render a table onto the surface of the browser. 149 00:14:36,080 --> 00:14:43,400 So all these activities now I will show you one by one with the help of an example that will cover all 150 00:14:43,400 --> 00:14:48,580 this flask, Ezekial actual alchemy features and functionality. 151 00:14:49,310 --> 00:14:52,160 So with the help of this example, we shall. 152 00:14:53,590 --> 00:14:58,870 You know, find out how to use the flask as Cual alchemy extension. 153 00:15:00,120 --> 00:15:09,000 Along with the flask application to, you know, manipulate or use as cool as you like, database. 154 00:15:10,210 --> 00:15:17,230 So first and foremost, we have to ensure that this extension flask, as alchemy is installed in the 155 00:15:17,230 --> 00:15:19,570 working environment of our flask application. 156 00:15:20,780 --> 00:15:24,920 So this is the virtual environment in which your flask is installed. 157 00:15:26,160 --> 00:15:28,650 So now you try to install the. 158 00:15:31,710 --> 00:15:33,570 Alchemy using the utility. 159 00:15:34,520 --> 00:15:35,750 So I will say. 160 00:15:41,730 --> 00:15:42,630 Name of the. 161 00:15:44,190 --> 00:15:47,100 Extension is Flask Eskil Alchemy. 162 00:15:51,570 --> 00:15:56,660 It says the government is already satisfied, that means for this extension is already present. 163 00:15:57,910 --> 00:16:06,010 You can also verify this by starting a python interpreter and you try to import that, so I will start 164 00:16:06,010 --> 00:16:10,660 the interpreter and right import statement. 165 00:16:15,210 --> 00:16:20,880 If this this instruction is accepted, then it means that it is installed otherwise not. 166 00:16:21,830 --> 00:16:23,390 There you see the. 167 00:16:24,370 --> 00:16:31,330 What are the package is already present, so that is our first requirement fulfilled. 168 00:16:33,080 --> 00:16:42,140 Next, we have a look at the Python code, which performs all the operations on the underlying Ezekial 169 00:16:42,140 --> 00:16:48,380 database using this Ezekial Flask, Eskil Iljimae extension. 170 00:16:49,800 --> 00:16:52,320 So these are our regular reports. 171 00:16:53,510 --> 00:17:01,280 For this particular exercise, you want to import this Ezekial Alchemy class from this. 172 00:17:02,600 --> 00:17:05,270 Lask, Eskil, Iljimae extension. 173 00:17:06,700 --> 00:17:08,830 These are all the imports. 174 00:17:11,110 --> 00:17:17,350 Then, of course, this is the last complication object, these two lines are the configuration of. 175 00:17:18,450 --> 00:17:21,720 Your app object is appropriate config. 176 00:17:23,090 --> 00:17:30,050 Ezekial Alchemy database, you are right, that means what you have to give the pot to the database 177 00:17:30,050 --> 00:17:34,940 that you are going to use the name of the databases to start escalate. 178 00:17:35,480 --> 00:17:40,730 Three, the protocol that you are going to use is CircuLite, Collen. 179 00:17:42,360 --> 00:17:49,650 Students will ask you like three, and then you have to set the secret key of your application by saying, 180 00:17:49,650 --> 00:17:52,980 I have not configured secret keys equal to this. 181 00:17:54,510 --> 00:17:58,000 OK, so this is, again, the configuration of your application object. 182 00:17:58,800 --> 00:18:06,450 Second step is to rather the third step is to declare an object of the actual alchemy class, which 183 00:18:06,450 --> 00:18:07,260 you are imported. 184 00:18:08,860 --> 00:18:09,760 It requires. 185 00:18:10,850 --> 00:18:19,490 This AP as an argument, so that is cruel alchemy, class object, I call it as D.B.. 186 00:18:21,030 --> 00:18:23,670 Now, in this debate, there is a different model. 187 00:18:24,480 --> 00:18:30,120 Now this our model is to be used as a base class for. 188 00:18:31,760 --> 00:18:32,570 Declaring a. 189 00:18:33,800 --> 00:18:35,780 Mappa class college students. 190 00:18:37,190 --> 00:18:46,250 Which means that this inside this student's database, there will be a table called the student's. 191 00:18:48,420 --> 00:18:48,900 And. 192 00:18:50,070 --> 00:18:55,710 This object of this student's class will be each role in the table. 193 00:18:56,720 --> 00:19:02,590 So naturally, what do you have to give the structure of that table? 194 00:19:04,450 --> 00:19:06,370 Now, this DBE. 195 00:19:07,590 --> 00:19:08,910 Object has a. 196 00:19:10,620 --> 00:19:12,960 My terror function, collegeboard.com. 197 00:19:16,740 --> 00:19:19,710 Requires, the argument says. 198 00:19:22,880 --> 00:19:25,520 The data type and the size. 199 00:19:26,910 --> 00:19:29,250 In the first place, the name of the. 200 00:19:31,420 --> 00:19:39,040 Feel will be student student ID, it's the data that will be in danger and it is to be set as the primary 201 00:19:39,040 --> 00:19:40,100 keys equal to true. 202 00:19:40,810 --> 00:19:43,450 So this is the first field second release name. 203 00:19:43,640 --> 00:19:44,590 They will not Collum. 204 00:19:44,800 --> 00:19:48,070 It will be a string containing a string, the top 200. 205 00:19:49,000 --> 00:19:57,090 Characters, the column again, it will be a string with 50 characters address up to 200 characters, 206 00:19:57,090 --> 00:19:59,920 string pin up to 10 characters string. 207 00:20:01,020 --> 00:20:03,870 So this is nothing but the structure of your table. 208 00:20:06,010 --> 00:20:11,260 OK, now, every time when you declare an object of this student's class. 209 00:20:13,080 --> 00:20:19,920 You know that whenever the object of a class is declared, the constructor goes to work and the constructor 210 00:20:19,920 --> 00:20:20,370 is in it. 211 00:20:21,490 --> 00:20:28,650 This constructor will be provided for arguments, each corresponding to the phrase name city address. 212 00:20:29,230 --> 00:20:33,850 So using these arguments, the object will be initialized. 213 00:20:35,860 --> 00:20:37,000 So later on. 214 00:20:38,170 --> 00:20:43,840 There will be an object of this Lowrance class declared, which will take for argument's. 215 00:20:45,150 --> 00:20:46,830 OK, so this is our modern. 216 00:20:48,180 --> 00:20:50,430 So three aspects we have seen. 217 00:20:51,870 --> 00:20:57,760 Import application, model, configuration and declaration of the model. 218 00:20:58,050 --> 00:20:58,890 So this is our. 219 00:20:59,950 --> 00:21:00,760 First step. 220 00:21:01,990 --> 00:21:02,530 Of the. 221 00:21:04,180 --> 00:21:04,960 Python called. 222 00:21:06,600 --> 00:21:11,610 In this flask, application to your rules are defined. 223 00:21:11,640 --> 00:21:15,030 One is the flash and the other is new. 224 00:21:16,380 --> 00:21:20,510 I will explain this to you first and then we'll go to this less. 225 00:21:21,520 --> 00:21:25,720 Slash new is map to a view function called new. 226 00:21:26,920 --> 00:21:34,190 Now, this you are maybe called the application may reach this, you are new. 227 00:21:35,240 --> 00:21:44,340 In two ways, one is if the user directly enters into his browser's address, bar localhost 5000 new. 228 00:21:45,370 --> 00:21:51,880 In that case, the method by which this you are reached or fired will not be possible, it will be get 229 00:21:52,330 --> 00:21:57,100 so therefore what will happen, this block will not be executed. 230 00:21:58,680 --> 00:22:06,440 This statement will be executed and what it is doing, it is rendering a new e-mail template on the 231 00:22:06,900 --> 00:22:07,320 browser. 232 00:22:08,880 --> 00:22:14,190 OK, so we will have to see what the new estimate. 233 00:22:17,660 --> 00:22:20,840 So this is the New Testament in which. 234 00:22:22,230 --> 00:22:23,130 This is a form. 235 00:22:24,650 --> 00:22:33,110 And in in the form, there are four text elements, one each for name, city address and penal code. 236 00:22:34,990 --> 00:22:37,290 Isn't it and then there is a submit button. 237 00:22:39,070 --> 00:22:44,530 When the user clicks after filling the form, when the user click on the submit button, it will be 238 00:22:44,530 --> 00:22:48,400 posted to the same order by the meter post. 239 00:22:50,890 --> 00:22:52,340 By the metal post. 240 00:22:52,930 --> 00:22:54,640 So what happens when? 241 00:22:56,070 --> 00:23:03,090 The form is posted there, or rather what happens when this when this new URL is reached with the post 242 00:23:03,100 --> 00:23:03,420 ometer? 243 00:23:04,440 --> 00:23:05,630 So let us go back. 244 00:23:07,390 --> 00:23:13,990 So in this case now, when, again, this new you are fired, now the matter is supposed so, therefore 245 00:23:13,990 --> 00:23:16,090 this block of statements will be executed. 246 00:23:18,650 --> 00:23:19,130 Isn't it? 247 00:23:20,180 --> 00:23:28,580 So if the matter is paused, but the form that has been posted containing four former elements name, 248 00:23:28,580 --> 00:23:33,650 city address and beancurd, any of those fields. 249 00:23:34,990 --> 00:23:35,650 Are empty. 250 00:23:37,270 --> 00:23:44,460 Then obviously those that should not be added, so therefore what what what is to be done, a message 251 00:23:44,470 --> 00:23:47,140 is to be flashed, an error message. 252 00:23:47,140 --> 00:23:48,970 Please enter all the names. 253 00:23:49,960 --> 00:23:55,530 And this flash function will generate a flash message which will be displayed on the browser when the 254 00:23:55,540 --> 00:23:57,790 next to you are released accessed. 255 00:23:58,930 --> 00:24:06,850 OK, but if this this form is properly filled, all the officials do have a certain value, then the 256 00:24:06,850 --> 00:24:08,760 else block will be executed here. 257 00:24:08,770 --> 00:24:14,530 The object of the student's class is created with four attributes or four parameters. 258 00:24:16,830 --> 00:24:22,040 Extracted from the request, not from object, the or form names addressed in court. 259 00:24:22,120 --> 00:24:28,140 This will be the values that will be released that will be corresponding to the estimable form data 260 00:24:28,800 --> 00:24:30,640 using or taking these values. 261 00:24:30,660 --> 00:24:32,530 This object is created. 262 00:24:33,390 --> 00:24:37,800 Now, this object is to be added into. 263 00:24:39,240 --> 00:24:48,570 The database that is right now in the session so deeply, not not at all what the student object. 264 00:24:49,700 --> 00:24:58,310 If it is properly executed, commit the operations by saying they will not commit and then the message 265 00:24:58,310 --> 00:25:02,480 to be flashed record, the message to be flashed as record was successfully ended. 266 00:25:02,990 --> 00:25:07,040 So either this message has to be flashed or this has to be flashed. 267 00:25:07,280 --> 00:25:14,240 Well, when this when your browser is redirected towards another, you are sure all. 268 00:25:15,640 --> 00:25:18,700 OK, so this is the activity, which is then. 269 00:25:20,020 --> 00:25:20,440 When? 270 00:25:21,580 --> 00:25:23,230 The user clicks on. 271 00:25:25,090 --> 00:25:27,950 The link, which takes it to this, uh. 272 00:25:28,950 --> 00:25:32,040 Insertion of new record activities done. 273 00:25:34,250 --> 00:25:41,750 Incidentally, what happens to the flash messages if the record if the data is not properly filled, 274 00:25:42,410 --> 00:25:44,180 that means if this condition is. 275 00:25:47,240 --> 00:25:47,600 Through. 276 00:25:48,680 --> 00:25:56,410 When will be either name or your address, it will not be entered, then this is the message to be flashed. 277 00:25:57,160 --> 00:26:02,740 As you know, the flash will be other messages will be flashed when the next. 278 00:26:03,890 --> 00:26:06,290 You are in our next review function is executed. 279 00:26:06,650 --> 00:26:08,880 So after this flash, what is going to happen? 280 00:26:08,900 --> 00:26:10,400 This is not going to take place. 281 00:26:10,420 --> 00:26:11,160 The blog. 282 00:26:12,290 --> 00:26:15,440 So the control of the program will come to this. 283 00:26:16,820 --> 00:26:24,740 So the in the New Testament, if the is improperly filled, the form must be shown again, but with 284 00:26:24,980 --> 00:26:25,940 an error message. 285 00:26:26,540 --> 00:26:31,250 So if you remember, if you will have a look at the will again. 286 00:26:34,800 --> 00:26:36,060 So this is the. 287 00:26:37,660 --> 00:26:46,150 Template to template code, which will take care of the messages to be fleshed, extract the messages 288 00:26:46,150 --> 00:26:50,380 by using the get flashed the messages function and display the. 289 00:26:51,390 --> 00:26:54,210 They called each function at a time and there will be only one. 290 00:26:55,490 --> 00:26:58,900 Indicating that there is an error in the form A.. 291 00:27:00,000 --> 00:27:00,330 Right. 292 00:27:00,360 --> 00:27:01,200 So this is the. 293 00:27:03,380 --> 00:27:11,900 Explanation for this part of your new rotation, so that takes us to this as look what happens in the 294 00:27:11,900 --> 00:27:15,950 health law when the data is properly filled up. 295 00:27:18,150 --> 00:27:22,980 What is going to happen, this object will be created and the record will be added. 296 00:27:25,090 --> 00:27:30,130 And the browser will be redirected towards the Schwall, sure all. 297 00:27:32,020 --> 00:27:34,030 The you are all for sure, all function. 298 00:27:37,120 --> 00:27:39,130 What is the you are in virtual function? 299 00:27:40,080 --> 00:27:44,580 This is the real virtual function, it is going to render the show all that e-mail. 300 00:27:46,160 --> 00:27:54,500 And it is going to take an attribute which is a result of this query, students not thrilled at all. 301 00:27:54,500 --> 00:28:00,920 All the records in the student's table will form a record set object. 302 00:28:01,870 --> 00:28:04,650 Which will be a value of this student sacrebleu. 303 00:28:06,430 --> 00:28:07,060 OK, so. 304 00:28:08,080 --> 00:28:15,070 Either by directly entering into the browser, localhost 5000 slash. 305 00:28:16,370 --> 00:28:22,760 This all e-mail will be rendered after completing or after performing the insert operation. 306 00:28:25,010 --> 00:28:32,390 After adding the record again, this sure all you are, which is against your or not e-mail will be 307 00:28:32,390 --> 00:28:32,820 displayed. 308 00:28:32,900 --> 00:28:34,160 So what does that insure? 309 00:28:34,160 --> 00:28:35,180 All that has to be. 310 00:28:38,050 --> 00:28:42,870 This is the extreme end quote for sure, all the e-mail. 311 00:28:45,730 --> 00:28:49,900 At the top, there is a there is, again, a template called. 312 00:28:52,030 --> 00:28:52,750 Which will. 313 00:28:57,950 --> 00:28:58,940 Rather this much. 314 00:29:00,450 --> 00:29:07,500 If there are if at all, there are any messages and there will be this message will be flashed when 315 00:29:07,890 --> 00:29:13,200 this show, all that estimate is going to be rendered after the successful completion of the insert 316 00:29:13,200 --> 00:29:13,660 operation. 317 00:29:13,680 --> 00:29:17,430 What is that, the record of a successful year that will be dispelled by this? 318 00:29:21,440 --> 00:29:23,600 Now, the rest of the team called. 319 00:29:24,540 --> 00:29:27,300 Is displaying a table. 320 00:29:28,180 --> 00:29:29,200 This is the table. 321 00:29:31,270 --> 00:29:33,670 Out of the first row is the. 322 00:29:34,940 --> 00:29:35,390 Hitting. 323 00:29:36,860 --> 00:29:37,910 Name, address. 324 00:29:38,740 --> 00:29:44,510 This will be appearing in the first row in the as if they are the. 325 00:29:45,830 --> 00:29:49,610 Fewer names on the titles of the table and. 326 00:29:51,240 --> 00:29:59,490 You know that the sure, all the testimony is going to be rendered with one parameter, which is the. 327 00:30:00,790 --> 00:30:06,160 In a record, the results of the query all function. 328 00:30:07,340 --> 00:30:09,650 They're not really all function. 329 00:30:11,040 --> 00:30:14,030 OK, so the student is it? 330 00:30:15,990 --> 00:30:17,880 List of all records. 331 00:30:18,000 --> 00:30:22,350 This is a list object of all the girls take one record at a time and. 332 00:30:23,370 --> 00:30:24,060 All the. 333 00:30:25,690 --> 00:30:31,120 Instance, variables of the student objects, not name, city address and pin code are displayed in. 334 00:30:32,170 --> 00:30:37,000 One group, one student object, that data is displayed in one room. 335 00:30:37,270 --> 00:30:45,400 Such like all the rooms will be integrated and it will complete a table of all the records in the student 336 00:30:45,610 --> 00:30:45,980 table. 337 00:30:48,290 --> 00:30:51,720 So this is the explanation of shouldered ASTM. 338 00:30:53,900 --> 00:31:00,620 So this student killer database is already present in our application folder. 339 00:31:01,340 --> 00:31:06,950 I am now showing you the calculator database using deescalates Tullio. 340 00:31:10,790 --> 00:31:16,620 And in this database, there is a table called restaurants, and this is the structure of the student. 341 00:31:16,640 --> 00:31:19,850 Remember, we have given this lecture in our students class. 342 00:31:20,720 --> 00:31:24,470 There are this is a primary key and these are the four. 343 00:31:26,380 --> 00:31:29,650 You know his name, address and phone call. 344 00:31:30,570 --> 00:31:36,120 Believe it or not, string is corresponding to or is being mapped to the worker sites. 345 00:31:37,100 --> 00:31:38,390 This was the site that was given. 346 00:31:39,990 --> 00:31:48,660 OK, and of which this student ID is the primary key that also we had given in our declaration of this 347 00:31:48,660 --> 00:31:49,460 student's class. 348 00:31:50,810 --> 00:31:55,890 Right, and right now, these phone records are already present in this. 349 00:31:58,380 --> 00:32:07,860 Not our intention is to just to verify whatever operation that we perform on this rescue database through 350 00:32:07,860 --> 00:32:14,970 our python code, whether they are, you can just verify that the operations are exactly stored and 351 00:32:14,970 --> 00:32:22,980 reflected in this year's kilojoule because they just show you that if the record is error, that should 352 00:32:22,980 --> 00:32:24,380 be visible here. 353 00:32:25,140 --> 00:32:29,330 And if the records are listed, those are listed on the list. 354 00:32:29,340 --> 00:32:29,760 Exactly. 355 00:32:29,760 --> 00:32:31,980 Should match with this list. 356 00:32:32,340 --> 00:32:35,430 That is the intention of showing you this close to you. 357 00:32:36,480 --> 00:32:41,820 Now, let us start our application brought from the command line. 358 00:32:45,940 --> 00:32:51,970 The server is running, there are some warnings with relation to the. 359 00:32:53,680 --> 00:33:00,560 The configuration of this flask, Ezekial Alchemy, but then you can ignore, uh, the subtle reasoning. 360 00:33:01,420 --> 00:33:07,870 So what we have to do now to go to the browser and give this you are localhost five thousand slash. 361 00:33:10,360 --> 00:33:12,010 So I entered this, you are in. 362 00:33:14,640 --> 00:33:23,340 Is giving the present list of records, and it is also giving me a link to Astroland, so it will take 363 00:33:23,340 --> 00:33:25,800 me to localhost 5000 new. 364 00:33:27,610 --> 00:33:29,050 So if I click on this new. 365 00:33:30,680 --> 00:33:31,400 There is a form. 366 00:33:32,990 --> 00:33:33,830 In this form. 367 00:33:39,910 --> 00:33:40,870 Something like this. 368 00:33:41,930 --> 00:33:42,860 And then submit. 369 00:33:47,740 --> 00:33:53,530 There you see the list is now updated, the fifth record Israel recorded successfully. 370 00:33:53,560 --> 00:33:55,000 This is the message that was flashed. 371 00:33:56,960 --> 00:33:59,150 So if I click on this ad student again. 372 00:34:00,190 --> 00:34:08,440 This will be, again, their eye without entering anything, I just submit it will prompt me, please 373 00:34:08,440 --> 00:34:15,310 enter all the so all the operations are now, you know, verified with the help of this. 374 00:34:15,820 --> 00:34:21,190 Let me go back to this rescue slue and see whether the newly added record is happening in that or not. 375 00:34:22,750 --> 00:34:29,380 So this is, again, the studio interface students database student stable. 376 00:34:29,650 --> 00:34:32,190 The fifth record added is being displayed here. 377 00:34:32,590 --> 00:34:39,670 So our insert operation is successful and the list is also properly being displayed on the browser. 378 00:34:39,670 --> 00:34:45,160 With the help of all this, we are done with the help of the Flask Eskil Alchemy Extension.