This repository was archived by the owner on May 13, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,6 +54,54 @@ czipdata.txt|纯真IPv4数据文本文件|TXT
5454ipv6data.txt|ZXinc_IPv6数据文本文件|TXT
5555correct.json|地址细分纠错文件|JSON
5656
57+ # IP查询
58+ ## 安装相关模块
59+ ``` powershell
60+ # 使用git前请先安装git软件
61+ git clone --depth=1 https://github.com/a76yyyy/ipdata.git
62+ cd ipdata
63+ # 安装gzip 解压data文件夹中的gz相关文件;
64+ # 使用sqlite3请先安装sqlite3软件, 数据库文件在data/ipdata.db.gz压缩档内;
65+ # 使用mysql请先安装mysql组件并导入sql脚本, sql脚本在data/ipdatabase.sql.gz压缩档内;
66+ # 进行下述操作前请先安装python3;
67+ pip3 install pipenv
68+ pipenv install
69+ pipenv shell
70+ python
71+ ```
72+ ## SQLite3 for Python3
73+ ``` python
74+ from database import sqlite3_Database
75+ from configs import config
76+ sqlite3file = config[' sqlite3' ].ip_database
77+ conn = sqlite3_Database(sqlite3file)
78+ ```
79+ ## MySQL for Python3
80+ ``` python
81+ from database import mysql_Database
82+ from configs import config
83+ conn = mysql_Database(config[' mysql' ].ip_database)
84+ ```
85+ ## IPv4 查询
86+ ``` python
87+ import ipaddress
88+ ip = ipaddress.IPv4Address(' 114.114.114.114' )
89+ sql = " select * from iprange_info where " + str (int (ip)) + " between ip_start_num and ip_end_num "
90+ print (conn.query(sql))
91+ ```
92+ ## IPv6 查询
93+ ``` python
94+ import ipaddress
95+ ip = ipaddress.IPv6Address(' 2400:3200::' )
96+ sql = " select * from ipv6_range_info where x'" + ' ' .join(ip.exploded.split(' :' )) + " ' between ip_start_num and ip_end_num "
97+ print (conn.query(sql))
98+ ```
99+ ## 退出
100+ ``` python
101+ conn.__del__ ()
102+ exit ()
103+ ```
104+
57105# TODO
58106
591071 . 实现data文件夹的分类存储;
Original file line number Diff line number Diff line change 77'''
88
99import os
10- sqltype = 'mysql'
10+
1111default_dat_update = True #执行ip_Sync.py时是否默认联网自动更新czipdata.dat文件, False为默认不更新, 不存在dat文件时该选项失效。
1212default_sqlite3_update = True #当执行ip_Sync.py时是否默认自动更新SQLite3数据库, False为默认不更新。
1313default_txt_update = False #当数据文件版本无更新时是否默认自动更新czipdata.txt文件, False为默认不更新。
You can’t perform that action at this time.
0 commit comments