Skip to content

A Python script to clear data from all tables in SQLite databases within a specified folder, while preserving the schema and table structures.

License

Notifications You must be signed in to change notification settings

DevaanshPathak/SQLite-DB-Cleaner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SQLite Data Cleaner

This script clears all data from .db files in a specified folder while preserving the database schema (tables and their structures). It iterates through each SQLite database, deletes the data from all tables, and leaves the table structures intact.


Update Required Path

Before running the script, you need to update the following variable with the appropriate path:

  • folder_with_dbs: The folder where your .db files are located.

Example:

Replace the placeholder with your actual path:

folder_with_dbs = r'C:\path\to\your\db\files'

Features

  • Clears data from all tables in .db files while keeping the schema intact.
  • Automatically detects and processes all .db files in the specified folder.
  • Safeguards database structure by not modifying tables or schema.

Requirements

  • Python: Version 3.12
  • SQLite: Built-in Python support (no external libraries required).

Installation

  1. Install Python 3.12 from the official Python website: https://www.python.org/downloads/.
  2. No external libraries are required, as SQLite is built into Python.

Usage

  1. Update the folder_with_dbs variable with the path to the folder containing .db files.
  2. Run the script:
    python clear_db_data.py
  3. The script will process all .db files in the specified folder and clear the data from all tables.

Example Workflow

  1. Place .db files in a folder, e.g., C:\Data\DB_Folder.
  2. Set folder_with_dbs to C:\Data\DB_Folder.
  3. Run the script to clear data from all tables in each .db file within the folder.

Notes

  • The script will not remove tables or modify the database schema, it only clears the data from the tables.
  • Ensure that the folder path is correctly specified and the .db files are valid SQLite databases.

Contributing

Feel free to fork the repository and submit pull requests for enhancements or bug fixes.


License

This project is licensed under the MIT License.


Support

For questions or issues, please open an issue in the repository or contact the maintainer.

About

A Python script to clear data from all tables in SQLite databases within a specified folder, while preserving the schema and table structures.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages