Delete Operation On Sqllite and Ms Access Database

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 11

GROUP 5 PRESENTATION

DELETE OPERATION ON SQL LITE AND Ms access

Shown nyamayaro r218549a


Shingai chifamba r211229A
Blessed nyakabau R2112051V
Chenai Isabel shumba r2113465t
Catherine dambakushamba r1913467c
WHAT IS
SQLLITE
• SQLite is a Relation Database Management System that is lightweight and easy to set up.
SQLite is serverless, which is its biggest advantage. It does not require a server to run a
database, unlike other RDMS like MySQL or PostgreSQL. So we don’t need any installation
setup.
• SQLite databases are stored locally, with files stored in the disk. This makes accessing and
managing the data in the database is remarkably fast.
SQLITE PYTHON: DELETING
DATA

• In order to delete data in the SQLite database from a Python program, we use the following
steps:

• First, establish a connection with the SQLite database by creating a Connection object using the
connect() function.
• Second, to execute a DELETE statement, you need to create a Cursor object using the cursor()
method of the Connection object.
• Third, execute the DELETE statement using the execute() method of the Cursor object. In case
you want to pass the arguments to the statement, you use a question mark ( ?) for each argument.
• The following create_connection() function establishes a database connection to an SQLite
database specified by a database file name:
CODE

• def del_report():
•     conn = sql.Connection(DATABASE)
•     cursor = conn.cursor()
•    
•     with conn:
•         cursor.execute('DELETE  FROM student_records WHERE
student_id = "T333" ')
•         print('deleted')
•        
MS-ACCESS DATABASE

• The first thing to do is to import the pyodbc (a python module that makes
accessing the ODBC databases simple. ODBC simply means Open Database
Connectivity.
• If you haven’t installed the pyodbc module, use pip install pyodbc
• The second thing is checking for the available drivers.
• The above code is to check for available drivers, and if you run the above code, you will the
following output:

• As you can see we have our driver now, and the only part we need is: MS-Access Drivers :
['Microsoft Access Driver (*.mdb, *.accdb)'
• Now we need to create connection between MS-Access and python.
• The code to create connection is as follows:
If you run the above code and there are no errors, a connection message is printed
(Connected to database)
The code for connecting to the database specifies the driver name, database name and the path
/ location of the database.
Now that we are connected to the database, it’s time to create the cursor object. This is done by
invoking the cursor() method on the connection object created.
After that, we execute the delete operation as follows:
 If there are no errors, the (deletion successful) message is printed.
 However you are not limited to this way only there are so many other ways to deal with
delete operation in MS-Access using python.
 The above database is the database with all entries

 Now this is showing that we have deleted the last entry


 However you are not limited to this way only there are so many other ways to deal with delete operation in MS-Access using
python.

You might also like