Skip to content
This repository was archived by the owner on May 13, 2022. It is now read-only.

Commit dc2fbe7

Browse files
committed
修复sqlite3 ipdata.db.gz导出bug
1 parent b5a08eb commit dc2fbe7

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

IP_Sync/convert.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ def convert_ip(sql_object, college_tablename, num_config, start_id, correct_list
6363

6464
if result_num == num_config:
6565
print( "本批次(行:" + str(start_id-1) + " - " + str( next_id - 2 ) + ")已处理完成。共需处理" + str(result_num) + "条,成功转换" + str(i) + "条。\n系统将自动处理下一批IP数据(行:" + str(next_id-1) + " - " + str(next_end_id-1) + ")…… \n---------------处理中, 请稍候---------------" )
66-
sql_object.__del__
66+
sql_object.__del__()
67+
if sqlite3file:
68+
sql_object = sqlite3_Database(sqlite3file)
69+
else:
70+
sql_object = mysql_Database(config['mysql'].ip_database)
6771
convert_ip(sql_object, college_tablename, num_config, next_id, correct_list, correct_json,sqlite3file=sqlite3file)
6872
else:
6973
print( "本批次(行:" + str(start_id-1) + " - " + str( start_id + result_num -2 ) + ")已处理完成。共需处理" + str(result_num) + "条,成功转换" + str(i) + "条。" )

IP_Sync/ip_Sync.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def sqldump(sql_file,table_college_info_sql_file,table_iprange_info_sql_file,tab
268268
def sqlite3dump(sqlite3file):
269269
print( "将SQLite3数据库压缩为gz文件: \n---------------处理中, 请稍候---------------")
270270
if default_gz_export:
271-
os.system('gzip %s' % ( sqlite3file))
271+
os.system('gzip -y %s' % ( sqlite3file))
272272
print( "SQLite3数据库gz压缩档导出成功! \n")
273273

274274
if __name__ == '__main__':
@@ -313,6 +313,9 @@ def sqlite3dump(sqlite3file):
313313
convertipv4(sqlite3,sqlite3file=sqlite3file)
314314
if ipv6update:
315315
db2SQLite3(sqlite3)
316-
sqlite3.__del__
316+
try:
317+
sqlite3.__del__()
318+
except:
319+
pass
317320
if ipv4update or ipv6update:
318321
sqlite3dump(sqlite3file)

0 commit comments

Comments
 (0)