标签:
#实时索引配置文件 index rt { type = rt path = C:\usr\local\coreseek-4.0.1-win32\var\data\rt #中文分词配置 charset_dictpath = C:\usr\local\coreseek-4.0.1-win32\etc\ charset_type = zh_cn.utf-8 #文档编号字段 #id #全文索引字段 rt_field = movie rt_field = url #属性字段 rt_attr_uint = groupid #存储内容字段,字符串类型 rt_attr_string = date rt_attr_string = movie rt_attr_string = url #RT实时索引内存设置 rt_mem_limit = 1024M } #searchd服务定义 searchd { workers = threads listen = 9312 listen = localhost:9306:mysql41 read_timeout = 5 max_children = 30 max_matches = 1000 seamless_rotate = 0 preopen_indexes = 0 unlink_old = 1 pid_file = C:\usr\local\coreseek-4.0.1-win32\var\log\searchd_rt.pid binlog_flush = 2 binlog_max_log_size = 16M }
import MySQLdb #connect to mysql db try: db = MySQLdb.connect(host="127.0.0.1", user="root", passwd="1234", port=9306) cursor = db.cursor() print "Connect to db successfully!" except: print "Fail to connect to db!" #insert data to db for line in open('C:\Users\Administrator\Desktop\ml-100k\u.item'): (identity,title,date,other,url) = line.split('|')[0:5] param = (identity,title,url,'1',date) sql = "insert into rt (id,movie,url,groupid,date) values(%s,%s,%s,%s,%s)" cursor.execute(sql,param) db.commit() db.close
标签:
原文地址:http://blog.csdn.net/ns2250225/article/details/43877419