参考文献生成项目,使用faiss实现
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
833 B

import pymysql
import json
# 建立数据库连接
connection = pymysql.connect(
host='rm-bp11ky2z5f34d2949fo.mysql.rds.aliyuncs.com',
user='fabiao_r',
password='f5u1w8nfb3b',
database='fabiao',
cursorclass=pymysql.cursors.DictCursor # 返回字典形式的结果,方便操作
)
try:
with connection.cursor() as cursor:
# 执行查询
sql = "SELECT * FROM spider_latest_journal_paper_list"
cursor.execute(sql)
# 获取查询结果
result = cursor.fetchall()
print(len(result))
# 处理结果
# for row in result:
# print(row)
with open("data/doctor_2018_2021.json", "w", encoding="utf-8") as f:
f.write(json.dumps(result, indent=2, ensure_ascii=False))
finally:
# 关闭连接
connection.close()