1
00:00:00,000 --> 00:00:05,000
So guys, now finally we will go ahead and start our development of our application.

2
00:00:05,000 --> 00:00:10,000
So here inside this I will go ahead and create my first app.py file.

3
00:00:10,000 --> 00:00:13,000
And this will be my Streamlit app.py file.

4
00:00:13,000 --> 00:00:19,000
So initially what I will do is that quickly go ahead with installing some of the basic libraries.

5
00:00:19,000 --> 00:00:26,000
So first of all I will go ahead and import Streamlit okay as St.

6
00:00:26,000 --> 00:00:32,000
So once we import the Streamlit uh, which we are basically going to use for our entire application,

7
00:00:32,000 --> 00:00:37,000
I'm also going to install one more library, which is called as Pathlib, so that I will be able to

8
00:00:37,000 --> 00:00:39,000
get my absolute path over here.

9
00:00:40,000 --> 00:00:45,000
Um, in, uh, c in Lang Chain, we have an agent, right.

10
00:00:45,000 --> 00:00:48,000
Which will actually help us to create the sequel agent itself.

11
00:00:48,000 --> 00:00:53,000
As I told you, at the end of the day, there will be a kind of sequel toolkit that we are going to

12
00:00:53,000 --> 00:00:58,000
run, and that entire toolkit will be able to run with the help of SQL agent itself.

13
00:00:58,000 --> 00:01:02,000
So in long chain you have something called as create sequel agent.

14
00:01:02,000 --> 00:01:06,000
So you can probably go ahead and just see the definition, uh, around it.

15
00:01:06,000 --> 00:01:10,000
So let me just show you once, like how you should probably go ahead and refer it.

16
00:01:10,000 --> 00:01:16,000
So here I'm going to go ahead and write long chain sequel agent okay.

17
00:01:16,000 --> 00:01:17,000
Create sequel agent.

18
00:01:17,000 --> 00:01:20,000
So let me just go ahead and write create sequel agent.

19
00:01:20,000 --> 00:01:24,000
So this is just like creating a different kind of agents itself, right?

20
00:01:24,000 --> 00:01:30,000
So once I click this here you will able to see about the create sequel agent.

21
00:01:30,000 --> 00:01:33,000
So that is what we are going to use over here.

22
00:01:33,000 --> 00:01:33,000
Right.

23
00:01:33,000 --> 00:01:36,000
And with the help of this create sequel agent.

24
00:01:36,000 --> 00:01:36,000
Right.

25
00:01:36,000 --> 00:01:42,000
So here you can see, uh, while using OpenAI function call API to drive this, we use this.

26
00:01:42,000 --> 00:01:47,000
And specifically if I go ahead and see this particular reference of create SQL agent.

27
00:01:47,000 --> 00:01:49,000
So here uh we are going to use this.

28
00:01:49,000 --> 00:01:54,000
It creates a SQL agent from an LM and toolkit or a database.

29
00:01:54,000 --> 00:01:54,000
Right.

30
00:01:54,000 --> 00:01:58,000
So this is what we are going to basically use over here right in our application.

31
00:01:58,000 --> 00:02:02,000
So for this we will be using uh create uh SQL agent.

32
00:02:02,000 --> 00:02:09,000
One more important uh thing that we use specifically for the SQL databases, this particular library,

33
00:02:09,000 --> 00:02:10,000
I'll talk about it.

34
00:02:10,000 --> 00:02:14,000
Why do we use it now after importing this particular library?

35
00:02:14,000 --> 00:02:17,000
Let's see what all other libraries we will be requiring.

36
00:02:17,000 --> 00:02:23,000
And as I said, you first of all, uh, there will be an agent that we really need to create and, uh,

37
00:02:24,000 --> 00:02:26,000
uh, the inbuilt sequel toolkit is also available.

38
00:02:26,000 --> 00:02:32,000
So for this we will be first of all using one agent type, then this Streamlit callback handler, which

39
00:02:32,000 --> 00:02:35,000
we have also used in our previous project.

40
00:02:35,000 --> 00:02:40,000
Uh, and this is what I'm actually talking about, the agent toolkits, which is nothing but the sequel

41
00:02:40,000 --> 00:02:42,000
database toolkit, which we are going to specifically use.

42
00:02:42,000 --> 00:02:43,000
Okay.

43
00:02:43,000 --> 00:02:48,000
Again, uh, you can go ahead and see in the documentation about this entire toolkit, more detail if

44
00:02:48,000 --> 00:02:50,000
you really want to know and understand.

45
00:02:50,000 --> 00:02:50,000
Okay.

46
00:02:51,000 --> 00:02:55,000
Now finally, what I will do is that I will go ahead and write from SQL alchemy.

47
00:02:55,000 --> 00:02:56,000
Okay.

48
00:02:56,000 --> 00:02:59,000
This is also what I'm actually going to use.

49
00:02:59,000 --> 00:03:05,000
Uh, SQL alchemy will actually help you to map with respect to the output that is specifically coming

50
00:03:05,000 --> 00:03:07,000
from your SQL database.

51
00:03:07,000 --> 00:03:07,000
Okay.

52
00:03:07,000 --> 00:03:11,000
So here we are going to import this something called as Create engine.

53
00:03:11,000 --> 00:03:14,000
Uh this is one of the another library that we will be using.

54
00:03:14,000 --> 00:03:15,000
Okay.

55
00:03:16,000 --> 00:03:19,000
Uh, along with this since we are also going to work with SQLite three.

56
00:03:19,000 --> 00:03:22,000
So I'm going to write SQLite three over here.

57
00:03:22,000 --> 00:03:23,000
Okay.

58
00:03:23,000 --> 00:03:31,000
And then finally since we are using uh lang chain underscore grok I'm going to go ahead and import Chad

59
00:03:31,000 --> 00:03:31,000
Grok okay.

60
00:03:31,000 --> 00:03:36,000
So this is what we will be using to interact with our open source LM model okay.

61
00:03:36,000 --> 00:03:44,000
Now quickly uh we will go ahead and set our page configuration of our Streamlit and our, our title.

62
00:03:44,000 --> 00:03:46,000
I'll say, hey Lang in chat with SQL DB.

63
00:03:46,000 --> 00:03:48,000
This will be the page title icon.

64
00:03:48,000 --> 00:03:52,000
I've used this particular bird symbol, which is very much famous in Streamlit.

65
00:03:52,000 --> 00:03:56,000
Almost everybody is creating this kind of application, uses this kind of bird symbol.

66
00:03:56,000 --> 00:04:05,000
Okay, uh, one major problem with, uh, Streamlit is that with the chat with SQL DB is that there

67
00:04:05,000 --> 00:04:08,000
may be some kind of vulnerable prompt injection.

68
00:04:08,000 --> 00:04:13,000
Okay, so prompt injection kind of warnings I can actually give it.

69
00:04:13,000 --> 00:04:15,000
So use a DB role with limited permission.

70
00:04:15,000 --> 00:04:21,000
So please make sure that you give this kind of warning so that it will be shown in the red color.

71
00:04:21,000 --> 00:04:21,000
Okay.

72
00:04:21,000 --> 00:04:24,000
So till now I'll just remove it.

73
00:04:24,000 --> 00:04:26,000
I will just try to add it in the later stages.

74
00:04:26,000 --> 00:04:31,000
Now quickly uh, I will go ahead and create my two local variables.

75
00:04:31,000 --> 00:04:32,000
So two global variables.

76
00:04:32,000 --> 00:04:33,000
One is my local DB.

77
00:04:33,000 --> 00:04:38,000
I'll say, hey, uh, I'll create this particular variable.

78
00:04:38,000 --> 00:04:42,000
I'll say, hey, use local underscore db, local DB over here okay.

79
00:04:42,000 --> 00:04:50,000
And then I will say for my sequel I will create this particular variable value use underscore my sequel.

80
00:04:50,000 --> 00:04:51,000
Okay.

81
00:04:51,000 --> 00:04:57,000
The reason is very much simple because I am trying to implement with respect to two databases okay.

82
00:04:57,000 --> 00:05:02,000
Now what we will do on the left hand side we will create some radio option.

83
00:05:02,000 --> 00:05:03,000
Okay.

84
00:05:03,000 --> 00:05:09,000
So here I'm going to basically go ahead and define some radio options radio button like kind of thing.

85
00:05:09,000 --> 00:05:10,000
So here I will go ahead and write radio opt.

86
00:05:11,000 --> 00:05:18,000
And here we are going to specifically use SQLite three database.

87
00:05:19,000 --> 00:05:20,000
By default.

88
00:05:20,000 --> 00:05:23,000
I will give two options with respect to this particular radio option.

89
00:05:23,000 --> 00:05:31,000
I'll say hey, the first DB is interact with the student dot db, and the second DB is nothing but connect

90
00:05:32,000 --> 00:05:36,000
to your SQL database.

91
00:05:36,000 --> 00:05:40,000
Okay, so these are the two things that I am going to specifically use.

92
00:05:40,000 --> 00:05:40,000
Okay.

93
00:05:40,000 --> 00:05:45,000
Then you have this selected underscore opt okay selected underscore opt.

94
00:05:45,000 --> 00:05:52,000
And here I'm going to basically use um I'm going to say hey create this two radio button on the side

95
00:05:52,000 --> 00:05:52,000
wise.

96
00:05:52,000 --> 00:05:56,000
So I'll say use dot sidebar dot radio.

97
00:05:56,000 --> 00:05:59,000
And here I'm going to basically use.

98
00:06:02,000 --> 00:06:07,000
Label I'll say hey choose the DB.

99
00:06:09,000 --> 00:06:13,000
Which you want to chat.

100
00:06:13,000 --> 00:06:13,000
Okay.

101
00:06:14,000 --> 00:06:16,000
Something like this.

102
00:06:16,000 --> 00:06:21,000
And here I will give two options which I've actually defined in my radio opt.

103
00:06:21,000 --> 00:06:21,000
Okay.

104
00:06:21,000 --> 00:06:24,000
So here my second parameter is something called as option.

105
00:06:24,000 --> 00:06:27,000
And here I'm going to basically define it to radio opt.

106
00:06:27,000 --> 00:06:33,000
So this in the left hand side in the sidebar, it just gives you a kind of two radio buttons which you

107
00:06:33,000 --> 00:06:33,000
can probably select.

108
00:06:33,000 --> 00:06:34,000
Okay.

109
00:06:34,000 --> 00:06:37,000
So all this information is done till here.

110
00:06:37,000 --> 00:06:40,000
Now let's say if I am selecting.

111
00:06:40,000 --> 00:06:40,000
So I will go ahead and write.

112
00:06:40,000 --> 00:06:43,000
If radio opt dot index what.

113
00:06:43,000 --> 00:06:47,000
Whenever I probably select uh this radio buttons I will be getting some kind of index.

114
00:06:47,000 --> 00:06:49,000
So here I'm going to write.

115
00:06:49,000 --> 00:06:56,000
If this opt dot selected operation or subtracted option is double equal to one, I am going to say that.

116
00:06:56,000 --> 00:06:58,000
See if you are selecting an.

117
00:06:58,000 --> 00:07:00,000
Every index in Python starts from zero.

118
00:07:00,000 --> 00:07:01,000
Similarly in radio option also.

119
00:07:01,000 --> 00:07:06,000
But my first option is with respect to the student dot db first, uh, sorry zeroth option.

120
00:07:06,000 --> 00:07:13,000
This is my zeroth index and this is my first index since I'm selecting, uh, the first index over here,

121
00:07:13,000 --> 00:07:21,000
then my DB or I will be sorry DB underscore URI will be nothing, but it will be.

122
00:07:21,000 --> 00:07:23,000
I'll be I'll just set it to my sequel.

123
00:07:23,000 --> 00:07:24,000
Okay.

124
00:07:24,000 --> 00:07:28,000
My sequel uh, over here I had created this particular variable.

125
00:07:28,000 --> 00:07:30,000
So my sequel is nothing, but it is saying use my sequel.

126
00:07:30,000 --> 00:07:31,000
Okay.

127
00:07:31,000 --> 00:07:35,000
And whenever we select my sequel, we need to show four more option.

128
00:07:35,000 --> 00:07:41,000
And this, my sequel is with respect to my local database that I've actually installed the the MySQL

129
00:07:41,000 --> 00:07:42,000
workbench.

130
00:07:42,000 --> 00:07:42,000
Okay.

131
00:07:42,000 --> 00:07:46,000
So here first of all I will be requiring MySQL host.

132
00:07:46,000 --> 00:07:50,000
And with this I will go ahead and write SD dot sidebar.

133
00:07:50,000 --> 00:07:53,000
Uh, again I see for this MySQL host.

134
00:07:53,000 --> 00:07:55,000
Also I will be requiring some information.

135
00:07:55,000 --> 00:07:56,000
Right?

136
00:07:56,000 --> 00:08:00,000
Without this information I will not be able to connect it to my MySQL workbench.

137
00:08:00,000 --> 00:08:06,000
So for connecting it I will be requiring some information like MySQL SD dot sidebar.

138
00:08:06,000 --> 00:08:13,000
I'll be using a text input and then say hey, provide my provide MySQL hostname.

139
00:08:13,000 --> 00:08:15,000
Okay, I will say like this.

140
00:08:16,000 --> 00:08:21,000
Okay, so this will be the first parameter that I will be requiring in order to connect it to my SQL

141
00:08:21,000 --> 00:08:22,000
workbench.

142
00:08:22,000 --> 00:08:22,000
Okay.

143
00:08:22,000 --> 00:08:27,000
Then the next thing that I actually require is my MySQL user.

144
00:08:27,000 --> 00:08:34,000
And here we are basically going to again go ahead and write SD dot sidebar dot text underscore input.

145
00:08:34,000 --> 00:08:40,000
And here I'm going to basically use my SQL user okay.

146
00:08:40,000 --> 00:08:42,000
What is my username.

147
00:08:42,000 --> 00:08:42,000
Okay.

148
00:08:42,000 --> 00:08:45,000
So this will be the second parameter that I will require.

149
00:08:45,000 --> 00:08:48,000
First provide my SQL host then my SQL user.

150
00:08:48,000 --> 00:08:57,000
Along with this I will also be requiring my password Write my sequel underscore password.

151
00:08:57,000 --> 00:09:02,000
These are the basic information, and I'll try to show you how we can map this with our MySQL workbench.

152
00:09:02,000 --> 00:09:07,000
Okay, so here I will just go ahead and create this particular variable MySQL password.

153
00:09:07,000 --> 00:09:13,000
And here also I will go ahead and write my dot sidebar dot text underscore input.

154
00:09:13,000 --> 00:09:17,000
And here I'm actually going to give my SQL password.

155
00:09:20,000 --> 00:09:25,000
And with respect to this I will go ahead and write type is equal to password okay.

156
00:09:26,000 --> 00:09:28,000
Here we are going to specifically give the password itself.

157
00:09:28,000 --> 00:09:32,000
Finally I will go ahead and write MySQL underscore db is equal to.

158
00:09:35,000 --> 00:09:37,000
SD dot sidebar.

159
00:09:37,000 --> 00:09:42,000
Because here also I have to give my database name which database I really need to interact.

160
00:09:42,000 --> 00:09:44,000
So text underscore input.

161
00:09:44,000 --> 00:09:47,000
And here I will be having my SQL database.

162
00:09:47,000 --> 00:09:53,000
So this all information uh the user needs to provide from the application itself okay.

163
00:09:54,000 --> 00:09:56,000
So that is the reason we are taking this information.

164
00:09:56,000 --> 00:09:57,000
Now what does this basically mean.

165
00:09:57,000 --> 00:10:01,000
Like if I go ahead and select connect to your MySQL database okay.

166
00:10:01,000 --> 00:10:06,000
If I go ahead and write like this, that basically means we are going to connect to our MySQL workbench.

167
00:10:06,000 --> 00:10:11,000
So for this you require information like MySQL host user password and db.

168
00:10:11,000 --> 00:10:11,000
Okay.

169
00:10:12,000 --> 00:10:18,000
Uh, this is all the information that will be definitely required if we select the first option.

170
00:10:18,000 --> 00:10:19,000
So I will go ahead and write in the else block.

171
00:10:19,000 --> 00:10:25,000
If we select the first option then my DB URI will be nothing, but it will be just pointing to this

172
00:10:25,000 --> 00:10:26,000
local DB.

173
00:10:26,000 --> 00:10:29,000
Local DB is nothing, but it says use local underscore DB.

174
00:10:29,000 --> 00:10:36,000
Okay Now finally, if this selection is done and you know that this all information will be displayed

175
00:10:37,000 --> 00:10:40,000
by taking all this information, I just need to connect it in the later stages.

176
00:10:40,000 --> 00:10:46,000
Now I also require one important API key that is my grok API key right.

177
00:10:47,000 --> 00:10:56,000
So here what I will do I will use this, uh I will say hey let's use this sidebar sidebar st.

178
00:10:56,000 --> 00:10:59,000
Dot sidebar.

179
00:10:59,000 --> 00:11:04,000
And I'm just going to say, hey, while we are using this, let's go ahead and use our text input.

180
00:11:05,000 --> 00:11:08,000
And inside this text input I'm going to give my label.

181
00:11:08,000 --> 00:11:12,000
The label will be grok API key.

182
00:11:13,000 --> 00:11:19,000
And the type will be password over here because I really want to keep this all things hidden.

183
00:11:19,000 --> 00:11:20,000
Okay.

184
00:11:20,000 --> 00:11:25,000
So this through this, we will be, uh, getting our API key.

185
00:11:25,000 --> 00:11:27,000
We'll be getting our DB ora and.

186
00:11:27,000 --> 00:11:33,000
All right, so now, uh, first of all, I need to make sure that all this radio option button needs

187
00:11:33,000 --> 00:11:37,000
to be selected, and this API key needs to be given.

188
00:11:37,000 --> 00:11:37,000
Right.

189
00:11:37,000 --> 00:11:41,000
Unless and until these two are not given, we cannot chat with the database.

190
00:11:41,000 --> 00:11:45,000
So what we'll do over here is that we'll write two important conditions.

191
00:11:45,000 --> 00:11:46,000
Okay.

192
00:11:46,000 --> 00:11:56,000
One is if not db underscore URI, then I will just go ahead and write s3.info.

193
00:11:56,000 --> 00:12:06,000
So inside s3.info I will go ahead and say please enter the database information and URI.

194
00:12:06,000 --> 00:12:07,000
Okay.

195
00:12:07,000 --> 00:12:11,000
So I'm just going to go ahead and tell you this information that I really want.

196
00:12:11,000 --> 00:12:14,000
Other than this if the API key is not given.

197
00:12:15,000 --> 00:12:19,000
So if I go ahead and write API underscore key I'll say s t.info.

198
00:12:19,000 --> 00:12:27,000
And here also I'll say hey please add the grok API key.

199
00:12:27,000 --> 00:12:27,000
Okay.

200
00:12:27,000 --> 00:12:30,000
So some kind of message if I'm not giving this to information okay.

201
00:12:31,000 --> 00:12:37,000
Now the next thing is that I will quickly go ahead and call my LM model.

202
00:12:37,000 --> 00:12:41,000
So here I will just go ahead and call my LM model.

203
00:12:41,000 --> 00:12:43,000
And here what we are going to basically use is nothing.

204
00:12:43,000 --> 00:12:45,000
But we are seeing chat grok.

205
00:12:46,000 --> 00:12:52,000
Uh, first of all I need to give my API key, which is nothing, but uh, the API key that I have actually

206
00:12:52,000 --> 00:12:52,000
created.

207
00:12:52,000 --> 00:12:53,000
Okay.

208
00:12:53,000 --> 00:12:55,000
So this will basically be my API key.

209
00:12:55,000 --> 00:12:55,000
Okay.

210
00:12:55,000 --> 00:12:57,000
It should be grok.

211
00:12:59,000 --> 00:13:01,000
Grok API key I guess.

212
00:13:01,000 --> 00:13:02,000
Okay.

213
00:13:03,000 --> 00:13:06,000
And this will basically be set to my API key over here.

214
00:13:06,000 --> 00:13:12,000
Then you have this model underscore name I will try to give my model underscore name over here.

215
00:13:12,000 --> 00:13:14,000
Uh for this case I will just use llama three.

216
00:13:14,000 --> 00:13:15,000
Again.

217
00:13:15,000 --> 00:13:18,000
It is up to you with respect to grok you can use any model that you want.

218
00:13:18,000 --> 00:13:21,000
Okay, so I have written llama three 8,000,000,008 192.

219
00:13:22,000 --> 00:13:27,000
And finally I'll go keep one more parameter that is streaming is equal to true okay.

220
00:13:27,000 --> 00:13:33,000
So once I get this LM model I'm going to use this LM model over here with my sequel toolkit.

221
00:13:33,000 --> 00:13:41,000
Right now I will go ahead and create one very important function that is called as configure.

222
00:13:43,000 --> 00:13:49,000
So here I will say configure underscore db I will go ahead and configure our db itself.

223
00:13:49,000 --> 00:13:55,000
And for this I will use a decorator which is called as SD dot cache a resource.

224
00:13:55,000 --> 00:13:59,000
We want to probably cache this because we don't have to connect each and every time.

225
00:13:59,000 --> 00:14:02,000
And here I will take the TTL.

226
00:14:02,000 --> 00:14:04,000
Time is equal to turnaround time.

227
00:14:04,000 --> 00:14:04,000
Sorry.

228
00:14:04,000 --> 00:14:06,000
Total time limit I guess.

229
00:14:06,000 --> 00:14:07,000
Yes.

230
00:14:07,000 --> 00:14:09,000
So this will be somewhere around two hours.

231
00:14:09,000 --> 00:14:11,000
I'm saying that till two hours.

232
00:14:11,000 --> 00:14:13,000
You can keep it in the cache here.

233
00:14:13,000 --> 00:14:16,000
The first parameter that I'm actually going to give is my db underscore uri.

234
00:14:17,000 --> 00:14:23,000
The second parameter that I really want to give is my SQL underscore host is equal to none.

235
00:14:23,000 --> 00:14:24,000
Okay.

236
00:14:24,000 --> 00:14:27,000
Because all this information I definitely require right.

237
00:14:27,000 --> 00:14:31,000
My sequel host I require then I require this my SQL sequel user.

238
00:14:31,000 --> 00:14:33,000
So I will go ahead and copy it over here.

239
00:14:33,000 --> 00:14:34,000
I'll set it to none.

240
00:14:34,000 --> 00:14:39,000
Right along with this, uh, I also require my sequel password.

241
00:14:39,000 --> 00:14:39,000
Right.

242
00:14:39,000 --> 00:14:44,000
So I will just keep this as none, because all this information, we are just going to explore it or

243
00:14:44,000 --> 00:14:45,000
take it from there.

244
00:14:45,000 --> 00:14:47,000
And by default we will be keeping it at none.

245
00:14:47,000 --> 00:14:48,000
Okay.

246
00:14:48,000 --> 00:14:50,000
And then you have also my SQL DB.

247
00:14:52,000 --> 00:14:54,000
So this will also be none.

248
00:14:54,000 --> 00:14:57,000
Okay, so all this information I'm actually specifically giving over here.

249
00:14:57,000 --> 00:15:01,000
And then we will close the bracket and open the function from here.

250
00:15:01,000 --> 00:15:01,000
Right.

251
00:15:01,000 --> 00:15:03,000
So I will go ahead and open the function.

252
00:15:03,000 --> 00:15:05,000
So this will basically be my configure DB.

253
00:15:05,000 --> 00:15:06,000
Now here I will just go ahead and write.

254
00:15:06,000 --> 00:15:13,000
If my db uri okay is equal to.

255
00:15:14,000 --> 00:15:25,000
If my db underscore URI whatever db uri that I'm assigning, if it is double equal to local DB, okay,

256
00:15:25,000 --> 00:15:33,000
if it matches the local DB, what we will do, we will go ahead and set up the file path to our DB file

257
00:15:33,000 --> 00:15:34,000
that is present over here.

258
00:15:34,000 --> 00:15:37,000
Because here this local DB is nothing but your SQLite DB right.

259
00:15:38,000 --> 00:15:44,000
So here we'll go ahead and write db file path db file path.

260
00:15:46,000 --> 00:15:50,000
File path is equal to.

261
00:15:50,000 --> 00:15:53,000
Here I'm going to quickly write path.

262
00:15:53,000 --> 00:15:57,000
And let me just give the file path like this.

263
00:15:57,000 --> 00:15:59,000
By default uh file path.

264
00:15:59,000 --> 00:16:06,000
And I'll say uh this this is just mainly to get your, uh, if you really want to understand what we

265
00:16:06,000 --> 00:16:10,000
are specifically doing this, if I just go ahead and write dot parent okay.

266
00:16:10,000 --> 00:16:15,000
This dot parent, uh, if you just go ahead and print this particular information with respect to this

267
00:16:15,000 --> 00:16:20,000
particular file and the file information that I'm actually giving is student dot db.

268
00:16:20,000 --> 00:16:21,000
Okay.

269
00:16:21,000 --> 00:16:23,000
This I will try to give it in the string wise.

270
00:16:23,000 --> 00:16:26,000
So this in short is creating a absolute path okay.

271
00:16:26,000 --> 00:16:27,000
Absolute path.

272
00:16:27,000 --> 00:16:30,000
So this will basically be your parent path itself right.

273
00:16:31,000 --> 00:16:32,000
Above this what exactly is present.

274
00:16:32,000 --> 00:16:39,000
And then here I will just write absolute get the path complete path and actually get the absolute path

275
00:16:39,000 --> 00:16:40,000
of it okay.

276
00:16:40,000 --> 00:16:43,000
So if you just go ahead and print it you will be able to understand.

277
00:16:43,000 --> 00:16:48,000
So if I go ahead and print over here I'll say DF file path okay.

278
00:16:48,000 --> 00:16:50,000
So this is my son DF.

279
00:16:50,000 --> 00:16:53,000
It should be DB okay db file path.

280
00:16:53,000 --> 00:16:55,000
So here also I will go ahead and write my db file path.

281
00:16:55,000 --> 00:16:59,000
I'll just go ahead and print it to just show you what will be the path that will be connected over here.

282
00:17:00,000 --> 00:17:05,000
Then uh, again uh, there are two lines of code that I'm going to execute after this.

283
00:17:05,000 --> 00:17:11,000
First of all, I will go ahead and write creator Lambda SQL connect, and this will be the same path

284
00:17:11,000 --> 00:17:13,000
that I will be using over here.

285
00:17:13,000 --> 00:17:17,000
Uh, the mode will be on read bytes write.

286
00:17:17,000 --> 00:17:20,000
We will be basically reading bytes from this particular SQL.

287
00:17:20,000 --> 00:17:25,000
So for this we use SQL three dot connect to connect to that particular file.

288
00:17:25,000 --> 00:17:26,000
And you are I is equal to true.

289
00:17:26,000 --> 00:17:29,000
And for this we'll be using a lambda function okay.

290
00:17:30,000 --> 00:17:37,000
Finally after executing this you will be seeing that we'll be returning the SQL database which will

291
00:17:37,000 --> 00:17:38,000
be engine inside this.

292
00:17:38,000 --> 00:17:44,000
So that is the reason you can see that we have imported lang chain dot SQL database import SQL database

293
00:17:44,000 --> 00:17:44,000
over here.

294
00:17:44,000 --> 00:17:47,000
So it is nothing but create engine SQL light over here.

295
00:17:47,000 --> 00:17:51,000
All the information uh, with respect to this and creator is equal to creator.

296
00:17:51,000 --> 00:17:55,000
Whatever information is present with respect to this particular file path, okay.

297
00:17:55,000 --> 00:17:58,000
And that is the parameter that is required in create engine.

298
00:17:58,000 --> 00:18:10,000
Now similarly here I will just go ahead and write l f db underscore URI is double equal to my SQL.

299
00:18:11,000 --> 00:18:18,000
Okay, if it is double equal to my SQL, then what we do over here, if it is not equal, uh, my uh,

300
00:18:18,000 --> 00:18:21,000
if it is double equal to my SQL.

301
00:18:21,000 --> 00:18:28,000
And first of all I will say condition if any of the parameter is missed, like if my SQL host, my SQL

302
00:18:28,000 --> 00:18:33,000
user, or my SQL password, or my SQL db, If this any of the information is not provided, then we

303
00:18:33,000 --> 00:18:35,000
are just going to go ahead and display state error.

304
00:18:35,000 --> 00:18:35,000
Okay.

305
00:18:36,000 --> 00:18:39,000
Uh, this is important so that we'll be able to handle the exception over here.

306
00:18:40,000 --> 00:18:42,000
Otherwise we will go ahead and return.

307
00:18:42,000 --> 00:18:45,000
And this is how you connect to the MySQL database okay.

308
00:18:45,000 --> 00:18:47,000
So this is important okay.

309
00:18:47,000 --> 00:18:54,000
So here uh what we will specifically say that if this is working absolutely fine I'm just going to say

310
00:18:54,000 --> 00:18:57,000
hey, return this entire information.

311
00:18:57,000 --> 00:19:00,000
So what we are returning over here SQL database Create engine.

312
00:19:00,000 --> 00:19:02,000
But here we are going to use my SQL connector.

313
00:19:04,000 --> 00:19:08,000
Usually when you are connecting to the MySQL workbench we basically use the MySQL connector.

314
00:19:09,000 --> 00:19:13,000
After this this entire URL will be basically created.

315
00:19:13,000 --> 00:19:15,000
Here you will be having your MySQL user.

316
00:19:15,000 --> 00:19:18,000
Then you will have your MySQL password.

317
00:19:18,000 --> 00:19:19,000
Then you will have your MySQL host.

318
00:19:19,000 --> 00:19:22,000
And finally you have to have your MySQL DB.

319
00:19:22,000 --> 00:19:22,000
Okay.

320
00:19:23,000 --> 00:19:28,000
And this is the way how you specifically connect to your MySQL database.

321
00:19:28,000 --> 00:19:32,000
And for that we use this particular create engine along with the SQL database.

322
00:19:32,000 --> 00:19:32,000
Right.

323
00:19:33,000 --> 00:19:37,000
So uh, this is how you basically go ahead and connect to the MySQL okay.

324
00:19:38,000 --> 00:19:40,000
So this all information is done.

325
00:19:40,000 --> 00:19:45,000
Either of these two options when we select uh this is how we configure the entire DB okay.

326
00:19:45,000 --> 00:19:50,000
Now uh, in our uh next video okay.

327
00:19:50,000 --> 00:19:50,000
In our next video.

328
00:19:50,000 --> 00:19:53,000
And before this, uh, I go ahead I have to call this configure DB.

329
00:19:53,000 --> 00:19:54,000
Right.

330
00:19:54,000 --> 00:20:02,000
So let's say if I go ahead and say if our DB underscore URI is a double equal to my SQL, then what

331
00:20:02,000 --> 00:20:06,000
we are going to do is that we are going to basically configure it.

332
00:20:06,000 --> 00:20:09,000
I'm going to write DB is equal to configure.

333
00:20:09,000 --> 00:20:11,000
I'll call this configure db function.

334
00:20:11,000 --> 00:20:14,000
And inside this I will give my db uri.

335
00:20:14,000 --> 00:20:16,000
First parameter is my db uri.

336
00:20:16,000 --> 00:20:22,000
The second parameter is my SQL host okay my SQL host over here.

337
00:20:25,000 --> 00:20:29,000
The third parameter is specifically called as my SQL user.

338
00:20:30,000 --> 00:20:34,000
The fourth parameter that I am actually giving is MySQL password.

339
00:20:34,000 --> 00:20:38,000
And the fifth parameter that I have is nothing but MySQL db.

340
00:20:39,000 --> 00:20:44,000
Okay, so all these parameters, we are passing it over here for this particular database and automatically

341
00:20:44,000 --> 00:20:46,000
it will configure this particular database.

342
00:20:46,000 --> 00:20:49,000
I will be getting this particular database from this particular function.

343
00:20:49,000 --> 00:20:49,000
Right.

344
00:20:49,000 --> 00:20:52,000
It is returning the SQL database itself in the else section.

345
00:20:52,000 --> 00:20:58,000
What I will do, I will just go ahead and say DB is equal to configure underscore db.

346
00:20:58,000 --> 00:21:00,000
And here I'm going to give my db array.

347
00:21:00,000 --> 00:21:04,000
So in this particular local DB case I just need to give my db URI.

348
00:21:04,000 --> 00:21:09,000
And automatically it will be able to take this entire information and it will be able to execute it.

349
00:21:09,000 --> 00:21:10,000
Okay.

350
00:21:11,000 --> 00:21:12,000
Uh, yes.

351
00:21:12,000 --> 00:21:16,000
Uh, I think uh, all the information is specifically done over here till here.

352
00:21:16,000 --> 00:21:21,000
Now in our next video, uh, I will start creating our toolkit.

353
00:21:21,000 --> 00:21:25,000
So this is for our whatever work we have basically done.

354
00:21:25,000 --> 00:21:30,000
This is mostly about connecting your database which database you are specifically connecting okay.

355
00:21:30,000 --> 00:21:39,000
Now whenever I try to use, uh, this toolkit, what I will do is that I'm actually using an LM model.

356
00:21:39,000 --> 00:21:44,000
I'll say, hey, please display the records of, uh, all the records in the student table.

357
00:21:44,000 --> 00:21:45,000
Then it should.

358
00:21:45,000 --> 00:21:48,000
This LM model will probably create a query for us.

359
00:21:48,000 --> 00:21:52,000
And then with the help of that particular query, we will try to interact with this.

360
00:21:52,000 --> 00:21:52,000
Right.

361
00:21:52,000 --> 00:21:53,000
Interact with our database.

362
00:21:53,000 --> 00:21:56,000
So that work is basically done by the toolkit itself.

363
00:21:56,000 --> 00:21:59,000
So that is what we are going to see in the next video.

364
00:21:59,000 --> 00:22:02,000
So I hope you are able to understand till here I hope we are going on.

365
00:22:02,000 --> 00:22:02,000
Good.

366
00:22:02,000 --> 00:22:06,000
So yes, in the next video we'll be discussing more about it.

367
00:22:06,000 --> 00:22:07,000
So yeah, I'll see you all in the next video.

368
00:22:07,000 --> 00:22:08,000
Thank you.

