手機號碼歸屬地SQLite數據庫
Github項目地址:https://github.com/lalala223/phone-dbgit
pip install phone-db
查詢數據庫中手機號段總條數github
>>> from phone_db import Session, Phone, Region >>> session = Session() >>> session.query(Phone).count() 415284
查詢北京市聯通手機號段總條數sql
>>> city = session.query(Region).filter_by(zip_code='100000').first() >>> if city: ... city.phones.filter_by(type=2).count() ... 6355
查詢指定手機號段歸屬地信息數據庫
>>> num = session.query(Phone).filter_by(number=1761166).first() >>> if num: ... num.detail() ... (1761166, '聯通', {'province': '北京', 'city': '北京', 'zip_code': '100000', 'area_code': '010'})
phones表session
id INTEGER NOT NULL, number INTEGER, type INTEGER, region_id INTEGER, PRIMARY KEY (id), FOREIGN KEY(region_id) REFERENCES regions (id)
regions表code
id INTEGER NOT NULL, province VARCHAR, city VARCHAR, zip_code VARCHAR, area_code VARCHAR, PRIMARY KEY (id)
* 1 移動 * 2 聯通 * 3 電信 * 4 電信虛擬運營商 * 5 聯通虛擬運營商 * 6 移動虛擬運營商
下載phone.db文件,使用sqlitebrowser查看sqlite
415284 (updated:2019年2月)ip