Complete Turkey administrative divisions database – All 81 provinces, 922 districts (+51 auto-generated province centers = 973 total) and 32,296 neighborhoods with SQL ready to import.
Türkiye'nin tüm idari bölünme verisi – 81 il, 922 ilçe (+51 otomatik il merkezi = 973 toplam) ve 32.296 mahalle verisiyle doğrudan SQL aktarım.
| Tablo & Kolon Ayarları | Dosya Seçimi | SQL Oluşturma |
|---|---|---|
![]() |
![]() |
![]() |
A desktop GUI application that reads Turkey's official province (İl), district (İlçe) and neighborhood (Mahalle) data from Excel files and generates SQL scripts for 4 different database engines. You can export as .sql file or push directly to your database.
This project is built on the official data published by the Republic of Turkey – Ministry of Interior:
🔗 e-İçişleri – Mülki İdari Bölümler (Administrative Divisions)
All default column mappings and row offsets are calibrated to the Excel format provided on this official government website.
If you don't want to run the tool, a pre-generated MSSQL script is available in the 2026TurkeySQL/ directory:
| File | Engine | Date | Description |
|---|---|---|---|
2026TurkeySQL/*.sql |
MSSQL | 13.03.2026 | Complete Turkey İl/İlçe/Mahalle data – ready to execute |
Simply run this
.sqlfile on your MSSQL server to get the full database without running the tool.
| Feature | Description |
|---|---|
| 4 SQL Engines | SQLite, PostgreSQL, MySQL, Microsoft SQL Server |
| GUI Interface | 4-tab Tkinter application – no command line needed |
| Customizable Schema | Table names, column names, data types, lengths, NULL constraints |
| Live Schema Preview | Real-time DDL preview as you change settings |
| Auto "İl Merkezi" District | 51 province centers auto-created – neighborhoods bound to a province center (not a named district) automatically get a synthetic district record (e.g. "Adıyaman İl Merkezi") inserted into the district table so that IlceId is never NULL |
| IF NOT EXISTS | Safe re-runs – tables are only created if they don't already exist |
| SQL File Export | Save generated SQL as .sql file |
| Direct DB Push | Write directly to your database via connection string |
| Excel Compat | Supports .xls (legacy) and .xlsx / .xlsm formats |
Some neighborhoods in the source data are linked directly to a province instead of a specific district (e.g. ADIYAMAN -> ADIYAMAN-İL MERKEZİ). When this happens, the tool automatically creates a district record named "{Province} İl Merkezi" in the district (İlçe) table with a unique ID and links all affected neighborhoods to it. This ensures:
- ✅
IlceIdcolumn is never NULL in the neighborhood table - ✅ Referential integrity is maintained across all foreign keys
- ✅ The auto-created districts are clearly marked with
-- Otomatik oluşturulan İl Merkezi ilçelericomment in SQL output
tr/
├── main.py # Entry point
├── README.md
├── requirements.txt
├── 2026TurkeySQL/ # Pre-generated MSSQL script (13.03.2026)
│ └── *.sql
└── src/
├── __init__.py
├── deps.py # Dependency management
├── utils.py # Turkish character helpers
├── parsers/
│ ├── __init__.py
│ ├── excel_reader.py # Excel file reader (.xls/.xlsx)
│ ├── il_parser.py # Province parser
│ ├── ilce_parser.py # District parser
│ └── mahalle_parser.py # Neighborhood parser
├── generators/
│ ├── __init__.py
│ └── sql_generator.py # SQL generator (DDL + DML)
├── db/
│ ├── __init__.py
│ └── push.py # Database push handler
└── gui/
├── __init__.py
├── constants.py # GUI constants
└── app.py # Main application window
- Python 3.8+
- Tkinter (bundled with Python)
pip install -r requirements.txtpython main.py- Tab 1 – Select SQL engine, customize table/column names if needed
- Tab 2 – Select the 3 Excel files downloaded from e-İçişleri
- Tab 3 – Click "Verileri Oku & SQL Oluştur" → preview & export SQL
- Tab 4 – Enter connection string → click "DB'ye Aktar" to push
| Engine | Example |
|---|---|
| SQLite | C:\database.db |
| PostgreSQL | host=localhost dbname=mydb user=postgres password=xxx |
| MySQL | host=localhost;port=3306;user=root;password=xxx;database=mydb |
| MSSQL | Server=94.x.x.x;Database=myDb;User Id=user;Password=pwd; |
Türkiye'nin resmi il, ilçe ve mahalle verilerini Excel dosyalarından okuyarak 4 farklı veritabanı motoruna uygun SQL scriptleri oluşturan masaüstü GUI uygulaması. Oluşturulan SQL'i .sql dosyası olarak dışa aktarabilir veya doğrudan veritabanınıza yazabilirsiniz.
Bu proje, T.C. İçişleri Bakanlığı tarafından yayımlanan resmi Mülki İdari Bölümler verisini kullanmaktadır:
Varsayılan sütun ve satır ayarları bu sitedeki Excel formatına göre kalibre edilmiştir.
Aracı çalıştırmak istemiyorsanız, 2026TurkeySQL/ dizininde MSSQL için hazır SQL scripti mevcuttur:
| Dosya | Motor | Tarih | Açıklama |
|---|---|---|---|
2026TurkeySQL/*.sql |
MSSQL | 13.03.2026 | Tüm Türkiye İl/İlçe/Mahalle verisi – doğrudan çalıştırılabilir |
Bu
.sqldosyasını MSSQL sunucunuzda çalıştırarak aracı kullanmadan tüm veritabanını elde edebilirsiniz.
| Özellik | Açıklama |
|---|---|
| 4 SQL Motoru | SQLite, PostgreSQL, MySQL, Microsoft SQL Server |
| GUI Arayüzü | 4 sekmeli Tkinter uygulaması – komut satırı gerektirmez |
| Özelleştirilebilir Şema | Tablo adları, kolon adları, veri tipleri, uzunluklar, NULL kısıtlamaları |
| Canlı Şema Önizlemesi | Ayarları değiştirdikçe DDL anlık güncellenir |
| Otomatik "İl Merkezi" İlçesi | 51 il merkezi otomatik oluşturulur – il merkezine bağlı mahalleler için ilçe tablosuna otomatik kayıt oluşturulur (örn: "Adıyaman İl Merkezi"), böylece IlceId asla NULL olmaz |
| IF NOT EXISTS | Tekrar çalıştırmada hata vermez – tablolar sadece yoksa oluşturulur |
| SQL Dosyası Dışa Aktarma | Oluşturulan SQL'i .sql olarak kaydedin |
| Doğrudan DB Aktarımı | Bağlantı dizesiyle doğrudan veritabanına yazın |
| Excel Uyumluluğu | .xls (eski format) ve .xlsx / .xlsm destekler |
Kaynak veride bazı mahalleler belirli bir ilçeye değil doğrudan il merkezine bağlıdır (örn: ADIYAMAN -> ADIYAMAN-İL MERKEZİ). Bu durumda uygulama otomatik olarak ilçe tablosuna "{İl Adı} İl Merkezi" adında bir kayıt oluşturur ve etkilenen tüm mahalleleri bu ilçeye bağlar:
- ✅ Mahalle tablosunda
IlceIdkolonu asla NULL olmaz - ✅ Tüm foreign key referansları sağlam kalır
- ✅ Otomatik oluşturulan ilçeler SQL çıktısında
-- Otomatik oluşturulan İl Merkezi ilçeleriyorumuyla işaretlenir
- Python 3.8+
- Tkinter (Python ile birlikte gelir)
pip install -r requirements.txtpython main.py- Sekme 1 – SQL motoru seçin, tablo/kolon adlarını özelleştirin
- Sekme 2 – e-İçişleri sitesinden indirdiğiniz 3 Excel dosyasını seçin
- Sekme 3 – "Verileri Oku & SQL Oluştur" → SQL'i önizleyin & dışa aktarın
- Sekme 4 – Bağlantı dizesini girin → "DB'ye Aktar" butonuyla veritabanına yazın
| Motor | Örnek |
|---|---|
| SQLite | C:\veritabani.db |
| PostgreSQL | host=localhost dbname=mydb user=postgres password=xxx |
| MySQL | host=localhost;port=3306;user=root;password=xxx;database=mydb |
| MSSQL | Server=94.x.x.x;Database=myDb;User Id=user;Password=pwd; |
| English | Türkçe | |
|---|---|---|
| 🔢 | AUTO INCREMENT is not used – IDs are assigned sequentially starting from 1 | AUTO INCREMENT kullanılmaz – ID'ler 1'den başlayarak sırayla atanır |
| 🔄 | Tables are created only if they don't exist (IF NOT EXISTS) | Tablolar sadece yoksa oluşturulur (IF NOT EXISTS) |
| 🏛️ | Unmatched neighborhoods get an auto-generated "İl Merkezi" district record | Eşleşmeyen mahalleler için otomatik "İl Merkezi" ilçe kaydı oluşturulur |
| 📊 | Data sourced from official e-İçişleri Excel files | Veri kaynağı resmi e-İçişleri Excel dosyalarıdır |
┌─────────────────────┐
│ Iller (İl) │
├─────────────────────┤
│ Id INT [PK] │
│ Adi NVARCHAR(100) │
└────────┬────────────┘
│ 1:N
▼
┌─────────────────────┐
│ Ilceler (İlçe) │
├─────────────────────┤
│ Id INT [PK] │
│ Adi NVARCHAR(100) │
│ IlId INT [FK] │──→ Iller.Id
└────────┬────────────┘
│ 1:N
▼
┌─────────────────────────┐
│ Mahalleler (Mahalle) │
├─────────────────────────┤
│ Id INT [PK] │
│ Adi NVARCHAR(500) │
│ IlId INT [FK] │──→ Iller.Id
│ IlceId INT [FK] │──→ Ilceler.Id
└─────────────────────────┘
Keywords / Anahtar Kelimeler: Turkey provinces SQL, Türkiye il ilçe mahalle veritabanı, Turkey administrative divisions database, Türkiye mülki idari bölümler SQL, Turkey city district neighborhood data, il ilçe mahalle SQL Server, Turkey geography database, Türkiye şehir ilçe mahalle listesi SQL, Turkey MSSQL PostgreSQL MySQL SQLite, e-icisleri mülki idari bölümler excel to sql
📄 License / Lisans: This project is open source. Data is sourced from the Republic of Turkey Ministry of Interior.
Bu proje açık kaynaklıdır. Veri kaynağı T.C. İçişleri Bakanlığı'dır.


