In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the details of MYSQL's data serialization Api interface. The content of the article is carefully selected and edited by the author. MYSQL's data serialization Api interface details have certain pertinence, which is of great significance to everyone's reference. Let's learn about the next topic with the author.
From flask import Flaskfrom flask import request Responseapp = Flask (_ _ name__) import osdef getApolloconf (k): import requests env = os.environ.get ("RUNTIME_ENV") or "dev" getApolloconfig = requests.get ('http://configserver-{env}.chj.cloud/configs/op-bmc-api/default/application'.format(env=env)) data = getApolloconfig.json () ["configurations"] return data.get (k) # get configuration insert Enter the database # def mysqlConfig (sql): import pymysql import json USERNAME = getApolloconf ("USERNAME") PASSWORD = getApolloconf ("PASSWORD") HOST = getApolloconf ("HOST") DATABASE = getApolloconf ("NGINXDATABASE") dbconfig = pymysql.connect (HOST USERNAME, PASSWORD, DATABASE) try: cursor = dbconfig.cursor () try: cursor.execute (sql) results = cursor.fetchall () reultData= [] columnList= ["run_type", "upstreamname", "front_listen", "domain_name", "backend_ip"] for row in results: reultData.append (zip (columnList) List (row) str1= (json.dumps (reultData, ensure_ascii=False)) return str1 except Exception as e: pass except Exception as err: print (err) def nginxtbale (): try: sql = "select run_type,upstreamname,front_listen,domain_name Backend_ip from nginxManager_dj_nginx_conf order by create_time "return mysqlConfig (sql) except Exception as e: # Roll back print (e) @ app.route ('/') def index () if an error occurs: import json return Response (json.dumps (nginxtbale ()), mimetype='application/json') if _ _ name__ = ='_ main__': app.run (host=" 192.168.1.1 " Port=8008, debug=True)
After reading the details of the Api interface for data serialization of MYSQL, many readers must have some understanding. If you need more industry knowledge and information, you can continue to follow our industry information column.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.