Skip to content

feat: migrate data layer to SQLite database and add Education module#6

Open
Ayesha-Anwar607 wants to merge 1 commit into
Inference-LAB:mainfrom
Ayesha-Anwar607:feat/ayesha-sqlite-migration
Open

feat: migrate data layer to SQLite database and add Education module#6
Ayesha-Anwar607 wants to merge 1 commit into
Inference-LAB:mainfrom
Ayesha-Anwar607:feat/ayesha-sqlite-migration

Conversation

@Ayesha-Anwar607

Copy link
Copy Markdown
Contributor

Summary of Changes

This PR migrates the data storage layer of faker-pk from hardcoded Python lists/dictionaries to a packaged, serverless SQLite database (faker_pk.db), and introduces a new Education module with realistic student profiles and institution filtering.


Key Improvements & Features Added

1. SQLite Database Storage Layer

  • Data Migration: Migrated all raw datasets (names, locations, job titles, industries, companies, SIM prefixes, castes, sects, banks) to a structured SQLite database.
  • Database Schema: Created 11 relational tables (industries, job_titles, companies, locations, names, sim_providers, sim_prefixes, castes, sects, banks, institutions) with proper foreign keys and constraints.
  • Auto-Initialization Fallback: Implemented an automatic database recreation check in faker_pk/utils.py so that if faker_pk.db is missing, it automatically regenerates from initialize_db.py.
  • Package Distribution: Updated pyproject.toml with setuptools package-data configuration to natively package *.db files inside wheels/tarballs.

2. Enhanced Data Logic & Realistic Relational Queries

  • Gender-Aware CNICs: cnic(gender=...) generates CNICs ending with an odd digit for males and an even digit for females.
  • Provider-Aware SIM Prefixes: phone_number(provider=...) pulls authentic mobile prefixes matching the specified telecom provider.
  • Cohesive Address Layouts: full_address() generates real, city-matched Pakistani postal codes alongside province filtering in city() and province().
  • Bank-Specific IBAN Codes: iban(bank=...) generates valid Pakistani IBAN formats utilizing authentic 4-letter bank codes (e.g. MEZN for Meezan Bank).
  • Expanded Industry Categories: Added 5 new industries: Art & Entertainment, Politics, Agriculture, Domestic & Personal Services, and Defense & Public Safety.

3. New Education Module (education.py)

  • Institution Generator: institution(level=..., city=..., province=...) generates schools, colleges, or universities filtered by level or location.
  • Age-Appropriate Student DOBs: student_dob(level=...) generates realistic birth dates matching institution age limits (5–14 for school, 14–18 for college, 18–25 for university).
  • Cohesive Student Profiles: student_profile(level=..., province=...) generates a complete dictionary containing consistent gender, CNIC, institution, city, province, and age-appropriate DOB.

Test Suite & Verification Results

  • Modular Test Architecture: Split education unit tests into single-purpose test files under tests/.
  • Relational Verification: Added 17 new unit tests in test_realistic_combinations.py testing CNIC gender alignment, address consistency, IBAN codes, SIM prefixes, and DB auto-initialization.
  • Results: All 41 unit tests passed successfully in 0.69s.
============================= 41 passed in 0.69s ==============================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant