adas100 commited on
Commit
a1dbbc3
1 Parent(s): caea21d

Upload sqlite.py

Browse files
Files changed (1) hide show
  1. sqlite.py +35 -0
sqlite.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sqlite3
2
+
3
+ ## Connectt to SQlite
4
+ connection=sqlite3.connect("student.db")
5
+
6
+ # Create a cursor object to insert record,create table
7
+
8
+ cursor=connection.cursor()
9
+
10
+ ## create the table
11
+ table_info="""
12
+ Create table STUDENT(NAME VARCHAR(25),CLASS VARCHAR(25),
13
+ SECTION VARCHAR(25),MARKS INT);
14
+
15
+ """
16
+ cursor.execute(table_info)
17
+
18
+ ## Insert Some more records
19
+
20
+ cursor.execute('''Insert Into STUDENT values('Krish','Data Science','A',90)''')
21
+ cursor.execute('''Insert Into STUDENT values('Sudhanshu','Data Science','B',100)''')
22
+ cursor.execute('''Insert Into STUDENT values('Darius','Data Science','A',86)''')
23
+ cursor.execute('''Insert Into STUDENT values('Vikash','DEVOPS','A',50)''')
24
+ cursor.execute('''Insert Into STUDENT values('Dipesh','DEVOPS','A',35)''')
25
+
26
+ ## Disspaly ALl the records
27
+
28
+ print("The isnerted records are")
29
+ data=cursor.execute('''Select * from STUDENT''')
30
+ for row in data:
31
+ print(row)
32
+
33
+ ## Commit your changes int he databse
34
+ connection.commit()
35
+ connection.close()