0% found this document useful (0 votes)
2 views1 page

Sqlite3 Practical

The document contains two Python programs that utilize SQLite to manage an Employee table. The first program creates the table and inserts three employee records, while the second program selects and displays employees with a salary greater than 55000. Both programs operate in memory and demonstrate basic database operations.

Uploaded by

ankushmahato789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Sqlite3 Practical

The document contains two Python programs that utilize SQLite to manage an Employee table. The first program creates the table and inserts three employee records, while the second program selects and displays employees with a salary greater than 55000. Both programs operate in memory and demonstrate basic database operations.

Uploaded by

ankushmahato789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Program 1: Create Employee Table

Write a program to create an Employee table and insert records.


import sqlite3

print("\nProgram 1: Create Employee Table\n")

conn = sqlite3.connect(":memory:")
cursor = conn.cursor()

cursor.execute("CREATE TABLE Employee (EmpID INTEGER PRIMARY KEY, Name TEXT, Salary INTEGER)")
cursor.executemany("INSERT INTO Employee VALUES (?, ?, ?)", [
(1, "Amit", 50000),
(2, "Neha", 60000),
(3, "Rajesh", 55000)
])

cursor.execute("SELECT * FROM Employee")


for row in cursor.fetchall():
print(row)

conn.close()

Program 2: Select Employees with Salary > 55000


Write a program to select employees whose salary is greater than 55000.
import sqlite3

print("\nProgram 2: Select Employees with Salary > 55000\n")

conn = sqlite3.connect(":memory:")
cursor = conn.cursor()

cursor.execute("CREATE TABLE Employee (EmpID INTEGER PRIMARY KEY, Name TEXT, Salary INTEGER)")
cursor.executemany("INSERT INTO Employee VALUES (?, ?, ?)", [
(1, "Amit", 50000),
(2, "Neha", 60000),
(3, "Rajesh", 55000)
])

cursor.execute("SELECT * FROM Employee WHERE Salary > 55000")


for row in cursor.fetchall():
print(row)

conn.close()

You might also like