# 将sqlite3中的数据转存到es中 import sqlite3 from elasticsearch import Elasticsearch es = Elasticsearch( ['192.168.137.67'], port=9200 ) conn = sqlite3.connect('test.db') c = conn.cursor() c.execute('SELECT * FROM test') while True: rec = c.fetchone() es.index(index="all", doc_type="url", id=None, body={"time":rec[0], "ip":rec[1], "user":rec[2], "category":rec[3], "connection":rec[4]}) if rec == None: break