This script converts .DBF files into SQLite databases, preserving table structure and data. It supports batch processing of all .DBF files in a folder, generating corresponding .db files in the specified output directory.
Before running the script, update the following variables with the appropriate paths:
input_folder: The folder where your.DBFfiles are located.output_folder: The folder where you want the generated SQLite.dbfiles to be saved.
Replace the placeholders with your desired paths:
input_folder = r'C:\path\to\your\dbf\files'
output_folder = r'C:\path\to\your\output\folder'- Converts
.DBFfiles into SQLite-compatible databases. - Automatically creates SQLite
.dbfiles for each.DBFfile in the input folder. - Handles date fields by converting them into
YYYY-MM-DDformat.
- Python: Version 3.12
- DBFread: Version 2.0.7
- Install Python 3.12 from the official Python website: https://www.python.org/downloads/.
- Install the required library:
pip install dbfread
- Update the
input_folderandoutput_foldervariables with your paths. - Run the script:
python dbf_to_sqlite.py
- SQLite
.dbfiles will be created in the specified output folder.
- All fields in the SQLite database are stored as
TEXTfor simplicity. Modify the script to customize field types if needed. - Ensure the
input_foldercontains valid.DBFfiles and theoutput_folderis writable.
- Place
.DBFfiles in a folder, e.g.,C:\Data\DBF_Files. - Set
input_foldertoC:\Data\DBF_Files. - Set
output_foldertoC:\Data\SQLite_Output. - Run the script to generate
.dbfiles inC:\Data\SQLite_Output.
Contributions are welcome! Fork the repository and submit pull requests for enhancements or bug fixes.
This project is licensed under the MIT License.
For questions or issues, please open an issue in the repository or contact the maintainer.