0% found this document useful (0 votes)
3 views3 pages

DBMS Exp7

The document outlines an experiment aimed at performing CRUD operations using Python with SQLite3. It explains the fundamental operations of Create, Read, Update, and Delete, along with their respective SQL syntax and common methods used in SQLite. The conclusion emphasizes the learning of SQLite as a fast and lightweight database engine.

Uploaded by

Mit
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)
3 views3 pages

DBMS Exp7

The document outlines an experiment aimed at performing CRUD operations using Python with SQLite3. It explains the fundamental operations of Create, Read, Update, and Delete, along with their respective SQL syntax and common methods used in SQLite. The conclusion emphasizes the learning of SQLite as a fast and lightweight database engine.

Uploaded by

Mit
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/ 3

Name : TEJAS JAGDISH LANDE

Registration no. : 221070035

EXPERIMENT 6

AIM : Write a program in a python to perform CRUD operations on database


(sqlite3/MYSql)

THEORY:
Python SQLite3 module is used to integrate the SQLite database with Python. It is a
standardized Python DBI API 2.0 and provides a straightforward and simple-to-use
interface for interacting with SQLite databases.
The abbreviation CRUD expands to Create, Read, Update and Delete. These four are
fundamental operations in a database. In the sample database, we will create it, and do
some operations.
CREATE:The create command is used to create the table in database.
SYNTAX: CREATE TABLE table_name ( Attr1 Type1, Attr2 Type2, … , Attrn Typen ) ;
INSERT: This refers to the insertion of new data into the table. Data is inserted in the
form of a tuple. The number of attributes in the tuple must be equal to that defined in the
relation schema while creating the table.
1. To insert attributes in the order specified in the relation schema:
SYNTAX:: INSERT INTO tableName VALUES ( value1, value2, … valuen )
2.To insert attributes in the order specified in the relation schema or in a different order:
SYNTAX: INSERT INTO tableName ( Attribute1, Attribute3, Attribute2 . . . ) VALUES (
value1, value3, value2 . . . )
READ: This refers to reading data from a database. A read statement has three
clauses:
SELECT: Takes as the predicate the attributes to be queried, use * for all attributes.
FROM: Takes as the predicate a relation.
WHERE: Takes as the predicate a condition, this is not compulsory.
UPDATE: This refers to the updating of tuple values already present in the table
SYNTAX: UPDATE tableName SET Attribute1 = Value1 , Attribute2 = Value2 , . . .
WHERE condition;
The WHERE clause must be included, else all records in the table will be updated.
DELETE: This refers to the deletion of the tuple present in the table.
SYNTAX: DELETE FROM tableName WHERE condition
If WHERE clause is not used then all the records will be deleted

Some common methods in SQLite used for performing CRUD operations are as follows:
1. sqlite3.connect(): It creates a connection to the database whose name is passed as
parameter in the current working directory, implicitly creating it if it does not exist:
2. cursor(): In order to execute SQL statements and fetch results from SQL queries, we
will need to use a database cursor.So this creates cursor to the database
3. execute(): It is used to execute a SQLite script in python.
4. commit(): It is the transactional command used to save changes invoked by a
transaction to the database.
5. close(): It is used to close the SQLite connection.

CODE & OUTPUT:


CONCLUSION: Thus by this experiment we learnt about one of the fastest,lightweight
and the most used database engines in the world i.e SQLite.We also learnt about some
common methods and some ways to perform the CRUD operation in our database.

You might also like