-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql.py
More file actions
41 lines (32 loc) · 1.31 KB
/
sql.py
File metadata and controls
41 lines (32 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# pip install db-sqlite3
# pip install sqlite3
import sqlite3
#Connectt to SQlite
#Our database name: Naresh_it_student
connection=sqlite3.connect("Naresh_it_employee1.db")
# Create a cursor object to insert record,create table
cursor=connection.cursor()
#create the table
#Our table name student
#Columns names are: name, course
table_info="""
Create table Naresh_it_employee1(employee_name varchar(30),
employee_role varchar(30),
employee_salary FLOAT);
"""
cursor.execute(table_info)
#Insert the records
cursor.execute('''Insert Into Naresh_it_employee1 values('Omkar Nallagoni','Data Science',75000)''')
cursor.execute('''Insert Into Naresh_it_employee1 values('Naresh','Data Science',90000)''')
cursor.execute('''Insert Into Naresh_it_employee1 values('Phani','Data Science',88000)''')
cursor.execute('''Insert Into Naresh_it_employee1 values('Naga babu','Data Engineer',50000)''')
cursor.execute('''Insert Into Naresh_it_employee1 values('Ajay','Data Engineer',35000)''')
cursor.execute('''Insert Into Naresh_it_employee1 values('Pawan','Data Engineer',60000)''')
#Disspaly ALl the records
print("The inserted records are")
data=cursor.execute('''Select * from Naresh_it_employee1''')
for row in data:
print(row)
#Commit your changes int he databse
connection.commit()
connection.close()