Get the App
SLTechnology News&Howtos  ›  Servers  › 

Details of Api API for data serialization of MYSQL

Shulou Source: shulou.com Published: 2022-06-03 06:38:28 09月11日 Update

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.

Tags: Data sequence interface details content author industry subject information meaning database article more friends column knowledge reader information or pertinence Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Linux Shulou Technology Shulou Tech Info macOS