Skip to main content

Detect mismatched column types & correct them in your database using SQLAlchemy .

Project description

🧠 dbtype_checker

A simple and lightweight tool to detect columns stored in the wrong data type in your database.
It connects to your SQL database, samples data, and infers the true data types using intelligent pandas-based logic.


🚀 Features

  • ✅ Detects int, float, bool, datetime, and str
  • ✅ Identifies type mismatches based on actual data values (not just schema)
  • ✅ Supports MySQL, PostgreSQL, and (optionally) Oracle
  • ✅ Can auto-fix mismatched columns (via ALTER TABLE)
  • ✅ Safe conversions with pre-cleaning (e.g., "true"/"false" to boolean)
  • ✅ No LLMs or external APIs — pure pandas + regex logic

📦 Installation

Install via pip:

pip install dbtype_checker " OR" pip install dbtype-checker==0.1.10


""" 
## EXAMPLE USAGE

For postgres:

from dbtype_checker.checker import run_type_check_and_fix

# Detection
run_type_check_and_fix("postgresql+pg8000://user:password@localhost/database_name"dry_run=True)
# Correction
run_type_check_and_fix("postgresql+pg8000://user:password@localhost/database_name"dry_run=False)

For MySQL:

from dbtype_checker.checker import run_type_check_and_fix

# Detection
run_type_check_and_fix("mysql+pymysql://user:password@localhost:port/database", dry_run=True)
# Correction
run_type_check_and_fix("mysql+pymysql://user:password@localhost:port/database", dry_run=False)

For Oracle:
from dbtype_checker.checker import run_type_check_and_fix

db_url = "oracle+cx_oracle://username:password@host:1521/?service_name=your_service_name"
# Detection
run_type_check_and_fix(db_url, dry_run=True)

#Correction
run_type_check_and_fix(db_url,dry_run=False)   

For CLI:

# Detection
python -m dbtype_checker.checker --db_url "postgresql+pg8000://user:password@localhost/dbname" --dry_run true

#Correction
python -m dbtype_checker.checker --db_url "mysql+pymysql://user:password@localhost/dbname" --dry_run false

"""

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbtype_checker-0.1.12.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbtype_checker-0.1.12-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file dbtype_checker-0.1.12.tar.gz.

File metadata

  • Download URL: dbtype_checker-0.1.12.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.2

File hashes

Hashes for dbtype_checker-0.1.12.tar.gz
Algorithm Hash digest
SHA256 170810b33adf8ec8723b86b5c2f3c1289d841bcfba0b59d841dc00ee576e5d04
MD5 4d6e810cf0f487d072ac958768876e04
BLAKE2b-256 6c7f896986c8485fca18b49042cf5b79e706f3d0c4f6bd636e23a143c93f792e

See more details on using hashes here.

File details

Details for the file dbtype_checker-0.1.12-py3-none-any.whl.

File metadata

File hashes

Hashes for dbtype_checker-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 81c2b07334ada7d8abf9407cc46cbde73028caf600d6af113535926ce6e046d0
MD5 b1a8b9193bfe97ae5e0e4e543c804a47
BLAKE2b-256 4a2cb906e4ff08da9f7973f6b093345c70a363f727a8c7ebdeef6c69a66dae98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page