当前位置: 首页 > news >正文

ppt背景图免费化工网站关键词优化

ppt背景图免费,化工网站关键词优化,短视频seo排名系统,科技公司起名字大全免费背景 日常开发过程中肯定会存在MySQL表数据迁移至ES的情况#xff0c;以canal为例#xff0c;数据迁移时需要提前在ES中创建索引Mapping#xff0c;但是如果碰到字段特别的表时#xff0c;创建Mapping将是一件耗费心神的事情。为了解决这些重复工作#xff0c;我使用Pyth…背景 日常开发过程中肯定会存在MySQL表数据迁移至ES的情况以canal为例数据迁移时需要提前在ES中创建索引Mapping但是如果碰到字段特别的表时创建Mapping将是一件耗费心神的事情。为了解决这些重复工作我使用Python编写了一个脚本自动将MySQL中的表结构同步到ES中本脚本只同步表结构并不同步表数据如需同步数据可以采用canal或者logstash等方式进行同步 脚本内容 如果不需要直接同步到es中需要注释脚本最后一行该脚本会将转换后的mapping信息打印到控制台中 import mysql.connector import requests import json# MySQL连接配置 mysql_config {host: 127.0.0.1,port: 3306,user: root,password: 123456,database: test }# Elasticsearch配置 es_host 127.0.0.1 es_port 9200 es_index order1# 新版本es不需求type字段 # es_type _docdef fetch_mysql_table_fields(mysql_config):connection mysql.connector.connect(**mysql_config)cursor connection.cursor()# 获取MySQL表字段信息,指定需要转换得表名cursor.execute(fDESCRIBE {order})fields cursor.fetchall()cursor.close()connection.close()return fieldsdef generate_es_mapping(fields):mapping {mappings: {properties: {}}}for field in fields:field_name field[0]field_type field[1]# 根据MySQL字段类型设置Elasticsearch映射类型es_field_type text # 默认为文本类型if int in field_type:es_field_type integerelif bigint in field_type:es_field_type longelif tinyint in field_type:es_field_type shortelif float in field_type:es_field_type floatelif double in field_type:es_field_type doubleelif decimal in field_type:es_field_type doubleelif date in field_type or datetime in field_type or timestamp in field_type or time in field_type:es_field_type dateelif json in field_type:es_field_type object# 这里可以根据需要添加更多类型的映射mapping[mappings][properties][field_name] {type: es_field_type}return mappingdef print_es_mapping(mapping):print(json.dumps(mapping, indent2))def create_es_index_mapping(es_host, es_port, es_index, mapping):url fhttp://{es_host}:{es_port}/{es_index}headers {Content-Type: application/json}payload json.dumps(mapping)response requests.put(url, headersheaders, datapayload)if response.status_code 200:print(fElasticsearch index mapping created for index {es_index})else:print(fFailed to create Elasticsearch index mapping. Status code: {response.status_code})print(response.text)if __name__ __main__:# 获取MySQL表字段信息table_fields fetch_mysql_table_fields(mysql_config)# 生成Elasticsearch Mappinges_mapping generate_es_mapping(table_fields)# 打印Elasticsearch Mapping到控制台print_es_mapping(es_mapping)# 创建Elasticsearch Index Mappingcreate_es_index_mapping(es_host, es_port, es_index, es_mapping)
http://www.zqtcl.cn/news/695139/

相关文章:

  • 有免费的微网站是什么可以做长图的网站
  • 南昌手机建站模板18种禁用软件黄app
  • 备案的域名做电影网站wordpress伪静态cdn配置
  • 国家城乡住房建设部网站百度关键词首页排名
  • 安卓软件开发需要学什么软件北京百度推广优化公司
  • 用asp.net 做网站wordpress网址缩短
  • 中国工程建设交易信息网站仿蘑菇街wordpress主题
  • 网站需要怎么做做普通网站公司吗
  • 网站收录平台方法网站建设是不是都需要交费
  • 上海 政务网站建设情况营销模式有哪些 新型
  • 国内做免费视频网站有哪些苏州娱乐场所最新消息
  • 福田建设网站宿迁网站建设案例
  • 建立企业网站的目的和意义人力资源外包收费标准
  • 网站开发前后端分离湘潭seo磐石网络
  • 上海做网站找谁京东网站建设分析
  • 叶榭做网站青岛做网站建设价格
  • 有什么可以在线做奥数题的网站中国建设网官网下载
  • 网站加载特效代码网站建设5000费用
  • 网站切图谁来完成wordpress 谷歌登陆
  • 租房网站建设网站怎么黑
  • 文成做网站搜索引擎优化工具深圳
  • 网站源码下载平台小程序云开发费用
  • 网站建设的数字化和互联网化网站作品
  • 南京专业网站制作公司有哪些亚马逊网网站建设规划报告
  • app免费制作网站模板网站打开速度进行检测
  • 进下加强新闻宣传网站建设wordpress做论坛网站
  • 朝阳网站搭建公司淘宝导购网站备案
  • 京润珍珠企业网站优化洛阳做网站
  • 嘉定网站开发中山市区做网站公司
  • 可信赖的武进网站建设上海中小企业服务中心