Skip to main content

手机号码SQLite数据库

Project description

phone-db

手机号码归属地SQLite数据库

安装

pip install phone-db

使用:

查询数据库中手机号段总条数
>>> from phone_db import Session, Phone, Region
>>> session = Session()
>>> session.query(Phone).count()
415284
查询北京市联通手机号段总条数
>>> 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表
id INTEGER NOT NULL,
number INTEGER,
type INTEGER,
region_id INTEGER,
PRIMARY KEY (id),
FOREIGN KEY(region_id) REFERENCES regions (id)
regions表
id INTEGER NOT NULL,
province VARCHAR,
city VARCHAR,
zip_code VARCHAR,
area_code VARCHAR,
PRIMARY KEY (id)

phones表type字段卡类型定义

* 1 移动
* 2 联通
* 3 电信
* 4 电信虚拟运营商
* 5 联通虚拟运营商
* 6 移动虚拟运营商

数据可视化

下载phone.db文件,使用sqlitebrowser查看

记录条数

415284 (updated:2019年2月)

数据来源

https://github.com/ls0f/phone

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

phone-db-1.0.2.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

phone_db-1.0.2-py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 3

Supported by

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