Total Pageviews

Sunday, 29 December 2024

SQLite: Installation, Checking, and Deleting Records

 1.Install SQLite:

sudo apt install sqlite3


Verify Installation ✅:

sqlite3 --version


2. Open Your Database 📂

Once SQLite is installed, you can open your database file:


Navigate to the Directory:

cd ~/appdata/arrr/jellyseerr/db

Open SQLite with Your Database:

sqlite3 db.sqlite3


3. Check for Existing Records 🔍

Before deleting any records, it’s good practice to check if they exist.


Run the Following Query:

SELECT media_request.id 

FROM media 

LEFT JOIN media_request ON media.id = media_request.mediaId 

WHERE media.status = 5;

Interpreting the Results:

The output will show IDs of media_request records that are linked to media entries with a status of 5.

Example Output:

1

3

5

7

8

9

10

11

14

15

28


4. Delete Records 

If you confirmed that records exist, you can proceed to delete them.


Run the Following Query:

DELETE FROM media_request 

WHERE id IN (

    SELECT media_request.id 

    FROM media 

    LEFT JOIN media_request ON media.id = media_request.mediaId 

    WHERE media.status = 5

);


5. Confirm Deletion ✔️

After deleting, it’s important to verify that the records have been removed.


Run the Check Again:

SELECT media_request.id 

FROM media 

LEFT JOIN media_request ON media.id = media_request.mediaId 

WHERE media.status = 5;

If the result set is empty, the deletion was successful! 🎉

Conclusion 🎈

You have successfully installed SQLite, checked for existing records, and deleted them as needed. 

No comments:

Post a Comment