Skip to content

AKJilani/Excel_To_SQLite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Excel to SQLite Importer

A fast, lightweight desktop tool to import Excel files (.xlsx / .xls) into a SQLite database. Built with Python and Tkinter — no browser, no internet, no installation required (when using the .exe).


Features

  • Import multiple Excel sheets into a single SQLite table called Data
  • Choose where to save the .db file using a standard Save As dialog
  • Performance presets to match your PC's RAM and CPU
  • Real-time progress bar showing current sheet and total row count
  • Stop button to cancel import at any time
  • Live log console inside the app
  • Works as a standalone .exe — no Python needed on target machines

Screenshots

UI includes: Excel file picker, Save location picker, Performance preset dropdown, Start/Stop buttons, Progress bar, and log console.


Requirements

If running from source:

Python 3.8+
openpyxl

Install dependency:

pip install openpyxl

Running from Source

python excel_to_sqlite.py

Building the .exe

Install PyInstaller:

pip install pyinstaller

Build the executable:

pyinstaller --onefile --windowed --name "ExcelToSQLite" excel_to_sqlite.py

The .exe will be output to:

dist\ExcelToSQLite.exe

No Python installation is required on the machine running the .exe.


How to Use

  1. Browse — Select your Excel file (.xlsx or .xls)
  2. Save As — Choose where to save the output .db file and give it a name
  3. Preset — Pick a performance level based on your PC specs
  4. START — Begin the import
  5. STOP — Cancel at any time (data inserted so far is saved)

Performance Presets

Preset Batch Size Cache Recommended For
Low 500 rows/tx 16 MB Old PCs, 2GB RAM
Medium 2,000 rows/tx 32 MB Average office PCs, 4–8GB RAM
High 5,000 rows/tx 64 MB i5 / 16GB+ RAM
Ultra 10,000 rows/tx 128 MB i7–i9 / 32GB+ RAM

Database Structure

All sheets from the Excel file are merged into a single table named Data.

  • The first row of each sheet is treated as column headers
  • An id column is automatically added as PRIMARY KEY AUTOINCREMENT
  • All columns are stored as NVARCHAR
  • Column names are sanitized to be valid SQL identifiers

Example

Given an Excel file with this structure:

SERIES_NUMBER IMAGE_NUMBER LINE NAME TYPE
d_001 img_001 1 Martha GIVENNAME

The resulting SQLite table Data will look like:

id SERIES_NUMBER IMAGE_NUMBER LINE NAME TYPE
1 d_001 img_001 1 Martha GIVENNAME

SQLite Speed Optimizations Applied

The following SQLite PRAGMAs are used internally for maximum import speed:

PRAGMA journal_mode = WAL        -- Write-Ahead Logging for faster writes
PRAGMA synchronous  = OFF        -- Skip fsync calls (biggest speed gain)
PRAGMA cache_size   = -N         -- Large in-memory page cache
PRAGMA temp_store   = MEMORY     -- Temp tables stored in RAM
PRAGMA locking_mode = EXCLUSIVE  -- No per-write lock overhead

Combined with large batch executemany() inserts inside explicit BEGIN / COMMIT transactions.


Notes

  • The sqlite_sequence table that appears in SQLite viewers is automatically created by SQLite to track AUTOINCREMENT counters. It is not your data — ignore it.
  • If the app is closed during import, the current batch is finished before the window closes.
  • Re-running the import on an existing .db file will append rows to the existing Data table. Delete the .db file first if you want a fresh import.

Project Structure

excel_to_sqlite.py   # Main application source
README.md            # This file
dist/
  ExcelToSQLite.exe  # Built executable (after running PyInstaller)

License

MIT License. Free to use, modify, and distribute.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages