内容简介:手机号码归属地SQLite数据库Github项目地址:查询数据库中手机号段总条数
手机号码归属地 SQLite 数据库
Github项目地址: github.com/lalala223/p…
安装
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 移动虚拟运营商 复制代码
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Mobilizing Web Sites
Layon, Kristofer / 2011-12 / 266.00元
Everyone has been talking about the mobile web in recent years, and more of us are browsing the web on smartphones and similar devices than ever before. But most of what we are viewing has not yet bee......一起来看看 《Mobilizing Web Sites》 这本书的介绍吧!