1
00:00:00,000 --> 00:00:01,000
Hello guys.

2
00:00:01,000 --> 00:00:03,000
So let's continue this specific project.

3
00:00:03,000 --> 00:00:06,000
And now we will go ahead and implement it step by step.

4
00:00:06,000 --> 00:00:14,000
Initially what we will do is that we will work with creating our data in our SQLite three database.

5
00:00:14,000 --> 00:00:19,000
And along with that, uh, you know, I will also be showing you how you can run the query in your SQL

6
00:00:19,000 --> 00:00:20,000
database.

7
00:00:20,000 --> 00:00:26,000
The prerequisite is that you really need to have some knowledge with respect to SQL database itself.

8
00:00:26,000 --> 00:00:32,000
You should at least know how to install this MySQL workbench which is available in my system right now.

9
00:00:32,000 --> 00:00:37,000
But I will just give you an idea from where you can go ahead and install it, and then you can probably

10
00:00:37,000 --> 00:00:38,000
continue, right?

11
00:00:38,000 --> 00:00:45,000
So first of all, let's go ahead and create my SQLite sqlite.py file.

12
00:00:45,000 --> 00:00:52,000
Now inside the sqlite.py file I will write all the code that is actually required in order to create

13
00:00:52,000 --> 00:00:55,000
the database in my SQLite three with the help of SQLite three database.

14
00:00:55,000 --> 00:00:59,000
So first of all, we will go ahead and import SQLite three.

15
00:00:59,000 --> 00:01:06,000
Remember SQLite three is uh like it will be inbuilt available with Python three itself, right?

16
00:01:06,000 --> 00:01:08,000
Or with the recent environment with respect to Python.

17
00:01:09,000 --> 00:01:10,000
Uh, right now I have Python 3.10.

18
00:01:10,000 --> 00:01:15,000
So obviously you will be able to have SQLite automatically installed.

19
00:01:15,000 --> 00:01:18,000
So I'm going to import SQLite three database.

20
00:01:18,000 --> 00:01:22,000
Then we will go ahead and write a code to connect to SQLite.

21
00:01:22,000 --> 00:01:22,000
Okay.

22
00:01:22,000 --> 00:01:25,000
Then here I'm going to basically go ahead and write.

23
00:01:25,000 --> 00:01:29,000
Connection is equal to SQLite three dot connect.

24
00:01:29,000 --> 00:01:35,000
I will say hey uh sorry SQLite three dot connect and I will give my database name.

25
00:01:35,000 --> 00:01:38,000
Let's say the database name is student dot db.

26
00:01:38,000 --> 00:01:39,000
Okay.

27
00:01:40,000 --> 00:01:51,000
Um, then we are going to create create a cursor object to insert a record.

28
00:01:52,000 --> 00:01:55,000
Create table okay.

29
00:01:55,000 --> 00:01:58,000
So we are going to basically go ahead and do this.

30
00:01:58,000 --> 00:02:05,000
And one more thing over here is that you really need to have cursor dot connection dot cursor okay.

31
00:02:05,000 --> 00:02:08,000
So we will be having this okay.

32
00:02:08,000 --> 00:02:09,000
And I will go ahead and create this.

33
00:02:09,000 --> 00:02:15,000
Then uh, let's go ahead and create the table okay.

34
00:02:15,000 --> 00:02:16,000
We are going to create the table over here.

35
00:02:16,000 --> 00:02:21,000
Now in order to create the table, first of all I'll give some table info and I will go ahead and write

36
00:02:21,000 --> 00:02:23,000
my command that is required.

37
00:02:23,000 --> 00:02:29,000
So uh, the sequel query for this will be create table table name which is nothing but student.

38
00:02:30,000 --> 00:02:32,000
I was a student here.

39
00:02:32,000 --> 00:02:34,000
The first parameter that I'm actually going to take is name.

40
00:02:34,000 --> 00:02:37,000
Name will be a vector.

41
00:02:37,000 --> 00:02:41,000
So I will say vector with respect to 25 characters.

42
00:02:41,000 --> 00:02:47,000
Then I'm going to put my another feature inside this particular table which will be my class.

43
00:02:47,000 --> 00:02:49,000
So I'll say hey class is nothing.

44
00:02:49,000 --> 00:02:51,000
But again it should be a vector.

45
00:02:52,000 --> 00:02:57,000
So here I will go ahead and or let me just go ahead and write all these things in the capital letter.

46
00:02:57,000 --> 00:02:57,000
Okay.

47
00:02:57,000 --> 00:03:02,000
So that will be able to distinguish with respect to a common query statement.

48
00:03:02,000 --> 00:03:04,000
So here I'm just going to say, hey, uh, let's go ahead.

49
00:03:04,000 --> 00:03:08,000
And first of all create the student table over here okay.

50
00:03:08,000 --> 00:03:15,000
And then I have my name varchar with respect to 25.

51
00:03:15,000 --> 00:03:23,000
Then I have my class where cat okay, it will be a bad cat where cat basically means it will have alphanumeric

52
00:03:23,000 --> 00:03:26,000
values and the maximum limit will be 25.

53
00:03:26,000 --> 00:03:27,000
Okay.

54
00:03:27,000 --> 00:03:29,000
Then we have let's say one more parameter.

55
00:03:29,000 --> 00:03:31,000
I'm going to take over here as section.

56
00:03:31,000 --> 00:03:36,000
And this will also be my berkat of 25 length.

57
00:03:36,000 --> 00:03:39,000
And finally I will have my marks.

58
00:03:39,000 --> 00:03:41,000
Marks can be of integer okay.

59
00:03:41,000 --> 00:03:46,000
So all these values I am basically this is the skeleton behind the entire table that we are going to

60
00:03:46,000 --> 00:03:47,000
create.

61
00:03:47,000 --> 00:03:47,000
Okay.

62
00:03:47,000 --> 00:03:55,000
Now in order to execute the SQL query and probably create this particular database and table in my SQLite

63
00:03:55,000 --> 00:04:00,000
three, I will just go ahead and use the same cursor and I'll go ahead and write dot execute.

64
00:04:00,000 --> 00:04:03,000
And I will give the table underscore info over here.

65
00:04:04,000 --> 00:04:10,000
So once I give the table info that basically means this entire query is going to get, uh, you know,

66
00:04:10,000 --> 00:04:15,000
quickly, uh, insert in sorry, this entire table will be created automatically.

67
00:04:15,000 --> 00:04:23,000
Now, the next thing is that after executing this, we will also go ahead and insert some more records.

68
00:04:23,000 --> 00:04:23,000
Okay.

69
00:04:24,000 --> 00:04:29,000
So for inserting some more records, what I will do is that I have written again this cursor.execute.

70
00:04:29,000 --> 00:04:35,000
And here you'll be able to see that I've used this insert into student values, uh, over here.

71
00:04:36,000 --> 00:04:39,000
And I've added values like crush data science a 90.

72
00:04:39,000 --> 00:04:42,000
So this basically means the first name of the student is crush.

73
00:04:42,000 --> 00:04:45,000
The class that crush is present is in data science.

74
00:04:45,000 --> 00:04:47,000
And then you have the section information.

75
00:04:47,000 --> 00:04:50,000
And finally you have the marks which is an integer value.

76
00:04:50,000 --> 00:04:56,000
Similarly, I have added more records over here with respect to John data science be insert into student

77
00:04:56,000 --> 00:05:01,000
values Mukesh data science a then you have insert into student values.

78
00:05:01,000 --> 00:05:05,000
Jacobs devops a uh 5050 is the marks.

79
00:05:05,000 --> 00:05:10,000
And finally you have this particular last, um, record that is basically being inserted.

80
00:05:10,000 --> 00:05:11,000
Okay.

81
00:05:11,000 --> 00:05:16,000
So once I go ahead and execute this cursor dot execute cursor dot execute automatically, it will make

82
00:05:16,000 --> 00:05:17,000
sure that it will display.

83
00:05:17,000 --> 00:05:19,000
It will insert all these records okay.

84
00:05:19,000 --> 00:05:26,000
Next uh, I will go ahead and display all the records okay.

85
00:05:28,000 --> 00:05:30,000
And here I'm going to go ahead and write print.

86
00:05:30,000 --> 00:05:36,000
And I'm going to say hey the inserted records are okay.

87
00:05:36,000 --> 00:05:42,000
And then we what we will do, we will go ahead and use another cursor.execute.

88
00:05:42,000 --> 00:05:46,000
And I'm going to basically go ahead and write select.

89
00:05:50,000 --> 00:05:59,000
Select Select star from student okay.

90
00:05:59,000 --> 00:06:04,000
So I'm just going to say hey select star from student over here in capital letters okay.

91
00:06:04,000 --> 00:06:08,000
And I'm going to probably retrieve all this particular result okay.

92
00:06:08,000 --> 00:06:14,000
Now once I execute all this select star from student, obviously I'm going to get 4 to 5 rows.

93
00:06:14,000 --> 00:06:17,000
So rows will be in the form of list over here.

94
00:06:17,000 --> 00:06:25,000
So what I will do I will go ahead and write hey for row in data okay data.

95
00:06:25,000 --> 00:06:29,000
And here I'm going to go ahead and print my row.

96
00:06:30,000 --> 00:06:39,000
Finally we will go ahead and commit your changes in the databases in the database.

97
00:06:39,000 --> 00:06:43,000
So for this I will go ahead and write connection dot close always.

98
00:06:43,000 --> 00:06:47,000
You need to write this one whenever you execute any query.

99
00:06:47,000 --> 00:06:47,000
Uh okay.

100
00:06:47,000 --> 00:06:52,000
So before the connection closing I will also go ahead and write connection dot commit okay.

101
00:06:53,000 --> 00:06:56,000
So this is how you basically go ahead and write this entire query.

102
00:06:56,000 --> 00:07:02,000
And quickly just under 5 to 10 minutes, I have written this entire thing where I have inserted some

103
00:07:02,000 --> 00:07:03,000
number of records.

104
00:07:03,000 --> 00:07:04,000
Okay, perfect.

105
00:07:04,000 --> 00:07:08,000
Uh, now what I will do, I will go ahead and open my terminal over here.

106
00:07:09,000 --> 00:07:11,000
So I'll go ahead and write CD dot dot.

107
00:07:11,000 --> 00:07:13,000
I will go to CD six.

108
00:07:13,000 --> 00:07:15,000
My charts equal okay.

109
00:07:15,000 --> 00:07:16,000
I will clear the screen.

110
00:07:16,000 --> 00:07:20,000
Now let me quickly go ahead and write Python C equal dot.

111
00:07:20,000 --> 00:07:25,000
Sorry SQLite sqlite.py.

112
00:07:25,000 --> 00:07:29,000
So once I execute this here you'll be able to see that it will go ahead and create this particular db.

113
00:07:29,000 --> 00:07:32,000
And inside this DB only we are creating this table right.

114
00:07:32,000 --> 00:07:34,000
So let's go ahead and execute it.

115
00:07:34,000 --> 00:07:39,000
And right now you can see nothing is there inside this particular file inside this folder.

116
00:07:39,000 --> 00:07:41,000
So let's go ahead and execute it.

117
00:07:41,000 --> 00:07:43,000
Now once I execute it here it shows okay.

118
00:07:43,000 --> 00:07:44,000
Cursor has no attribute.

119
00:07:44,000 --> 00:07:45,000
Cursor.

120
00:07:45,000 --> 00:07:46,000
Do you mean cursor okay.

121
00:07:46,000 --> 00:07:47,000
Line number seven.

122
00:07:47,000 --> 00:07:48,000
Let's see.

123
00:07:49,000 --> 00:07:52,000
Uh connection dot cursor okay.

124
00:07:52,000 --> 00:07:53,000
Perfect.

125
00:07:53,000 --> 00:07:57,000
Now what is, uh, we will usually get this kind of error.

126
00:07:57,000 --> 00:08:00,000
Now I will go ahead and write Python SQL dot p y.

127
00:08:00,000 --> 00:08:03,000
So here you can see the inserted records.

128
00:08:03,000 --> 00:08:05,000
I will also make sure that the spelling is right for this.

129
00:08:05,000 --> 00:08:07,000
So inserted records is all these things.

130
00:08:07,000 --> 00:08:09,000
And here you can see student dot DB.

131
00:08:09,000 --> 00:08:14,000
So I have actually prepared my data with respect to one of the SQLite database.

132
00:08:15,000 --> 00:08:18,000
And now you have the student dot db available over here.

133
00:08:20,000 --> 00:08:28,000
Now similarly I will also go ahead and do the same thing for my SQL server, um, which will be a standalone

134
00:08:28,000 --> 00:08:31,000
application, which you can also install it in your local machine.

135
00:08:31,000 --> 00:08:31,000
Okay.

136
00:08:31,000 --> 00:08:34,000
And that is what I'm actually going to show you in the next video.

137
00:08:35,000 --> 00:08:40,000
Um, as a prerequisite for this project, you at least need to have some idea about the SQL database.

138
00:08:40,000 --> 00:08:44,000
Okay, so that is the reason why I'm telling you that without that, if you don't know how to install

139
00:08:44,000 --> 00:08:48,000
SQL server, uh, then, uh, it'll be difficult for you all to understand.

140
00:08:48,000 --> 00:08:48,000
Okay.

